From f330cefd9da932120e24af4a201004cffa808297 Mon Sep 17 00:00:00 2001 From: Tom Owers Date: Thu, 30 Jul 2026 11:28:55 +0100 Subject: [PATCH 1/2] fix(data-imports): reuse resolved delta table in compact/vacuum maintenance Compaction and vacuum used to re-fetch the delta table via `get_delta_table()` after already resolving it moments earlier in the same call, even though `get_delta_table()`'s cache is only opportunistic. A concurrent sync of a different table can evict this table's cache entry mid-flight, so the redundant re-fetch could come back `None` and raise "Deltatable not found" right after a successful compact. This reuses the table reference already in hand across `compact_table`, `vacuum_if_stale`, and `compact_if_fragmented` instead of re-deriving it. Generated-By: PostHog Code Task-Id: c87d168c-c8b4-4ce2-9b72-d24d57864a60 --- .../pipelines/core/delta_table_helper.py | 39 +++++++++------ .../core/test/test_delta_table_helper.py | 48 +++++++++++++++---- 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py index ea946a7d16e4..119b8a9ab7de 100644 --- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py +++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py @@ -926,29 +926,37 @@ async def has_batch_been_committed(self, run_uuid: str, batch_index: int) -> boo """ return await self.has_commit_with_metadata({"run_uuid": run_uuid, "batch_index": str(batch_index)}) - async def vacuum_table(self) -> None: - table = await self.get_delta_table() - if table is None: - raise Exception("Deltatable not found") - + async def _vacuum(self, table: deltalake.DeltaTable) -> None: await self._logger.adebug("Vacuuming table...") vacuum_stats = await asyncio.to_thread( table.vacuum, retention_hours=24, enforce_retention_duration=False, dry_run=False ) await self._logger.adebug(json.dumps(vacuum_stats)) - async def compact_table(self) -> None: - table = await self.get_delta_table() - if table is None: - raise Exception("Deltatable not found") - + async def _compact(self, table: deltalake.DeltaTable) -> None: await self._logger.adebug("Compacting table...") compact_stats = await self._execute_with_conflict_retry( table, lambda: table.optimize.compact(), "compact_table" ) await self._logger.adebug(json.dumps(compact_stats)) - await self.vacuum_table() + async def vacuum_table(self) -> None: + table = await self.get_delta_table() + if table is None: + raise Exception("Deltatable not found") + + await self._vacuum(table) + + async def compact_table(self) -> None: + table = await self.get_delta_table() + if table is None: + raise Exception("Deltatable not found") + + await self._compact(table) + # Reuse the table already resolved above instead of re-fetching it: `get_delta_table` + # is cached only opportunistically, so a re-fetch here can race a concurrent sync of a + # different table evicting this table's cache entry and spuriously report it missing. + await self._vacuum(table) await self._logger.adebug("Compacting and vacuuming complete") async def vacuum_if_stale(self, last_vacuum_version: int | None, commit_threshold: int) -> int | None: @@ -987,7 +995,7 @@ async def vacuum_if_stale(self, last_vacuum_version: int | None, commit_threshol await self._logger.ainfo( f"vacuum_if_stale: {commits_since} commits since last vacuum (>= {commit_threshold}), vacuuming" ) - await self.vacuum_table() + await self._vacuum(table) try: # Observability for the maintenance path — how often tables vacuum and how much log churn # accrued between vacuums. Best-effort: telemetry must never break the sync. @@ -1027,7 +1035,7 @@ async def compact_if_fragmented( arrive here with None. Returns True if compaction ran, False if it was skipped. Cheap when the table is - healthy: one S3 LIST via `get_file_uris`. Intended for pre-write defensive cleanup + healthy: one S3 LIST via `table.file_uris`. Intended for pre-write defensive cleanup so a sync that arrived at a fragmented state (e.g. an earlier attempt that failed before reaching `_post_run_operations`) cleans up before adding to the pile. """ @@ -1035,7 +1043,7 @@ async def compact_if_fragmented( if table is None: return False - file_uris = await self.get_file_uris() + file_uris = await asyncio.to_thread(table.file_uris) total_files = len(file_uris) if partition_count is None: # One directory per partition value; unpartitioned tables collapse to the single @@ -1057,7 +1065,8 @@ async def compact_if_fragmented( return False await self._logger.ainfo(f"compact_if_fragmented: triggering compact ({stats})") - await self.compact_table() + await self._compact(table) + await self._vacuum(table) return True async def run_maintenance( diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py index 644c6f62feb9..a1f58e4af4bd 100644 --- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py +++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py @@ -283,12 +283,13 @@ async def test_threshold( expected_ran: bool, ): helper = DeltaTableHelper(resource_name="t", job=MagicMock(), logger=_make_logger()) - mock_delta = MagicMock() file_uris = [f"s3://bucket/table/f{i}.parquet" for i in range(file_count)] + mock_delta = MagicMock() + mock_delta.file_uris = MagicMock(return_value=file_uris) with ( patch.object(helper, "get_delta_table", AsyncMock(return_value=mock_delta)), - patch.object(helper, "get_file_uris", AsyncMock(return_value=file_uris)), - patch.object(helper, "compact_table", AsyncMock()) as mock_compact, + patch.object(helper, "_compact", AsyncMock()) as mock_compact, + patch.object(helper, "_vacuum", AsyncMock()) as mock_vacuum, ): kwargs: dict = {"partition_count": partition_count} if threshold_kw is not None: @@ -297,9 +298,11 @@ async def test_threshold( assert ran is expected_ran if expected_ran: - mock_compact.assert_called_once() + mock_compact.assert_called_once_with(mock_delta) + mock_vacuum.assert_called_once_with(mock_delta) else: mock_compact.assert_not_called() + mock_vacuum.assert_not_called() # (case_name, files_per_dir, dir_count, expected_ran) _DERIVATION_CASES: list[tuple[str, int, int, bool]] = [ @@ -325,18 +328,43 @@ async def test_partition_count_derived_from_layout( for d in range(dir_count) for i in range(files_per_dir) ] + mock_delta = MagicMock() + mock_delta.file_uris = MagicMock(return_value=file_uris) with ( - patch.object(helper, "get_delta_table", AsyncMock(return_value=MagicMock())), - patch.object(helper, "get_file_uris", AsyncMock(return_value=file_uris)), - patch.object(helper, "compact_table", AsyncMock()) as mock_compact, + patch.object(helper, "get_delta_table", AsyncMock(return_value=mock_delta)), + patch.object(helper, "_compact", AsyncMock()) as mock_compact, + patch.object(helper, "_vacuum", AsyncMock()) as mock_vacuum, ): ran = await helper.compact_if_fragmented(partition_count=None) assert ran is expected_ran if expected_ran: - mock_compact.assert_called_once() + mock_compact.assert_called_once_with(mock_delta) + mock_vacuum.assert_called_once_with(mock_delta) else: mock_compact.assert_not_called() + mock_vacuum.assert_not_called() + + +class TestCompactTable: + @pytest.mark.asyncio + async def test_does_not_refetch_table_for_the_vacuum_step(self, helper: DeltaTableHelper): + # Regression: compact_table used to finish its own compact, then call vacuum_table(), + # which called get_delta_table() again instead of reusing the table already in hand. + # get_delta_table() is cached only opportunistically (a concurrent sync of a different + # table can evict this table's cache entry), so that second call could come back None + # and raise "Deltatable not found" right after a successful compact. Asserting a single + # get_delta_table() call locks in that the vacuum step reuses the resolved table instead + # of re-deriving it. + mock_delta = MagicMock() + mock_delta.optimize.compact = MagicMock(return_value={}) + mock_delta.vacuum = MagicMock(return_value=[]) + with patch.object(helper, "get_delta_table", AsyncMock(return_value=mock_delta)) as mock_get: + await helper.compact_table() + + mock_get.assert_called_once() + mock_delta.optimize.compact.assert_called_once() + mock_delta.vacuum.assert_called_once() class TestGetDeltaTableUnrecoverableErrors: @@ -1134,13 +1162,15 @@ async def test_vacuum_cadence( table.version = MagicMock(return_value=150) with ( patch.object(helper, "get_delta_table", new=AsyncMock(return_value=table)), - patch.object(helper, "vacuum_table", new=AsyncMock()) as vacuum, + patch.object(helper, "_vacuum", new=AsyncMock()) as vacuum, patch(f"{module}.posthoganalytics") as ph, ): result = await helper.vacuum_if_stale(last_version, 100) assert result == expected_return assert vacuum.await_count == (1 if expect_vacuum else 0) + if expect_vacuum: + vacuum.assert_awaited_once_with(table) # The observability event fires exactly when a vacuum runs — not on seed/skip — so the cadence is measurable. assert ph.capture.call_count == (1 if expect_vacuum else 0) if expect_vacuum: From a03002f357ff92a022763e79ba220f81da445f12 Mon Sep 17 00:00:00 2001 From: "tests-posthog[bot]" <250237707+tests-posthog[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2026 10:47:13 +0000 Subject: [PATCH 2/2] test(backend): update query snapshots --- .../test_groups_revenue_analytics.ambr | 1021 ---- .../test/__snapshots__/test_persons.ambr | 125 - .../test_persons_revenue_analytics.ambr | 2131 +-------- .../test_session_replay_events.ambr | 142 - .../test/__snapshots__/test_sessions_v3.ambr | 112 - ...est_session_v2_where_clause_extractor.ambr | 140 - ...est_session_v3_where_clause_extractor.ambr | 93 - .../test_session_where_clause_extractor.ambr | 95 - .../test/__snapshots__/test_database.ambr | 30 - .../test/__snapshots__/test_action.ambr | 22 - .../test/__snapshots__/test_cohort.ambr | 97 - .../test/__snapshots__/test_printer.ambr | 4113 ++--------------- .../test/__snapshots__/test_mapping.ambr | 18 - 13 files changed, 452 insertions(+), 7687 deletions(-) diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.ambr index 337f36671231..2a11c04efec3 100644 --- a/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.ambr +++ b/posthog/hogql/database/schema/test/__snapshots__/test_groups_revenue_analytics.ambr @@ -228,421 +228,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestGroupsRevenueAnalytics.test_get_mrr_via_lazy_join_for_events[new_events_schema] - ''' - SELECT groups.key AS key, - groups__revenue_analytics.revenue AS revenue, - groups__revenue_analytics.mrr AS mrr - FROM ( - SELECT argMax(groups.group_key, - toTimeZone(groups._timestamp, - 'UTC')) AS groups___key, - groups.group_type_index AS index, - groups.group_key AS key - FROM groups - WHERE equals(groups.team_id, - 99999) - GROUP BY groups.group_type_index, - groups.group_key) AS groups - LEFT JOIN ( - SELECT 99999 AS team_id, - coalesce(revenue_agg.group_key, - mrr_agg.group_key) AS group_key, - coalesce(revenue_agg.revenue, - accurateCastOrNull(0, - 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, - accurateCastOrNull(0, - 'Decimal64(10)')) AS mrr - FROM ( - SELECT arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - WHERE notEmpty(group_key) - GROUP BY group_key) AS revenue_agg - FULL OUTER JOIN ( - SELECT customer_to_group.group_key AS group_key, - sum(coalesce(mrr_by_customer.mrr, - accurateCastOrNull(0, - 'Decimal64(10)'))) AS mrr - FROM ( - SELECT DISTINCT revenue_analytics_revenue_item.customer_id AS customer_id, - arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - WHERE notEmpty(group_key)) AS customer_to_group - LEFT JOIN ( - SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM ( - SELECT union.source_label AS source_label, - union.customer_id AS customer_id, - union.subscription_id AS subscription_id, - argMax(union.amount, - union.timestamp) AS mrr - FROM ( - SELECT revenue_item.source_label AS source_label, - revenue_item.customer_id AS customer_id, - revenue_item.subscription_id AS subscription_id, - toStartOfMonth(toTimeZone(revenue_item.timestamp, - 'UTC')) AS timestamp, - sum(revenue_item.amount) AS amount - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, - isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'))) - GROUP BY revenue_item.source_label, - revenue_item.customer_id, - revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL - SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, - toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, - 'UTC') AS timestamp, - accurateCastOrNull(0, - 'Decimal64(10)') AS amount - FROM ( - SELECT subscription_id AS id, - 'revenue_analytics.events.purchase' AS source_label, - NULL AS plan_id, - product_id AS product_id, - toString(person_id) AS customer_id, - NULL AS status, - min_timestamp AS started_at, - if(greater(max_timestamp_plus_dropoff_days, - today()), NULL, - max_timestamp_plus_dropoff_days) AS ended_at, - NULL AS metadata - FROM ( - SELECT events__person.id AS person_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - NULL AS product_id, - min(toTimeZone(events.timestamp, - 'UTC')) AS min_timestamp, - max(toTimeZone(events.timestamp, - 'UTC')) AS max_timestamp, - addDays(max_timestamp, - 45.0) AS max_timestamp_plus_dropoff_days - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - LEFT JOIN ( - SELECT person.id AS id - FROM person - WHERE equals(person.team_id, - 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, - person.version), 0), less(argMax(toTimeZone(person.created_at, - 'UTC'), person.version), plus(now64(6, - 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id), events__person.id) - WHERE and(equals(events.team_id, - 99999), and(1, - isNotNull(subscription_id))) - GROUP BY subscription_id, - person_id) - ORDER BY started_at DESC) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` - WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, - customer_id, - subscription_id - ORDER BY customer_id ASC, - subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_by_customer ON equals(customer_to_group.customer_id, - mrr_by_customer.customer_id) - GROUP BY group_key) AS mrr_agg ON equals(revenue_agg.group_key, - mrr_agg.group_key)) AS groups__revenue_analytics ON equals(groups.groups___key, - groups__revenue_analytics.group_key) - WHERE equals(groups.key, - 'lolol0:xxx') - LIMIT 100 SETTINGS format_csv_allow_double_quotes=1, - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestGroupsRevenueAnalytics.test_get_mrr_via_lazy_join_for_schema_source ''' SELECT groups.key AS key, @@ -1089,210 +674,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestGroupsRevenueAnalytics.test_get_revenue_for_events[new_events_schema] - ''' - SELECT groups.key AS key, - groups__revenue_analytics.revenue AS revenue, - groups__revenue_analytics.revenue AS `$virt_revenue` - FROM - (SELECT argMax(groups.group_key, toTimeZone(groups._timestamp, 'UTC')) AS groups___key, - groups.group_type_index AS index, - groups.group_key AS key - FROM groups - WHERE equals(groups.team_id, 99999) - GROUP BY groups.group_type_index, - groups.group_key) AS groups - LEFT JOIN - (SELECT 99999 AS team_id, - coalesce(revenue_agg.group_key, mrr_agg.group_key) AS group_key, - coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM - (SELECT arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM - (SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, 'UTC') AS timestamp, - timestamp AS created_at, - 0 AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - NULL AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - WHERE notEmpty(group_key) - GROUP BY group_key) AS revenue_agg - FULL OUTER JOIN - (SELECT customer_to_group.group_key AS group_key, - sum(coalesce(mrr_by_customer.mrr, accurateCastOrNull(0, 'Decimal64(10)'))) AS mrr - FROM - (SELECT DISTINCT revenue_analytics_revenue_item.customer_id AS customer_id, - arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key - FROM - (SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, 'UTC') AS timestamp, - timestamp AS created_at, - 0 AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - NULL AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - WHERE notEmpty(group_key)) AS customer_to_group - LEFT JOIN - (SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM - (SELECT union.source_label AS source_label, - union.customer_id AS customer_id, - union.subscription_id AS subscription_id, - argMax(union.amount, union.timestamp) AS mrr - FROM - (SELECT revenue_item.source_label AS source_label, - revenue_item.customer_id AS customer_id, - revenue_item.subscription_id AS subscription_id, - toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, - sum(revenue_item.amount) AS amount - FROM - (SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, 'UTC') AS timestamp, - timestamp AS created_at, - 0 AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - NULL AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - GROUP BY revenue_item.source_label, - revenue_item.customer_id, - revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, - toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, 'UTC') AS timestamp, - accurateCastOrNull(0, 'Decimal64(10)') AS amount - FROM - (SELECT '' AS id, - '' AS source_label, - '' AS plan_id, - '' AS product_id, - '' AS customer_id, - '' AS status, - toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS started_at, - toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS ended_at, - '' AS metadata - WHERE 0) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` - WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, - customer_id, - subscription_id - ORDER BY customer_id ASC, - subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_by_customer ON equals(customer_to_group.customer_id, mrr_by_customer.customer_id) - GROUP BY group_key) AS mrr_agg ON equals(revenue_agg.group_key, mrr_agg.group_key)) AS groups__revenue_analytics ON equals(groups.groups___key, groups__revenue_analytics.group_key) - WHERE equals(groups.key, 'lolol0:xxx') - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestGroupsRevenueAnalytics.test_get_revenue_for_schema_source_for_email_join ''' SELECT groups.key AS key, @@ -2721,408 +2102,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestGroupsRevenueAnalytics.test_query_revenue_analytics_table_events[new_events_schema] - ''' - SELECT groups_revenue_analytics.group_key AS group_key, - groups_revenue_analytics.revenue AS revenue, - groups_revenue_analytics.mrr AS mrr - FROM ( - SELECT 99999 AS team_id, - coalesce(revenue_agg.group_key, - mrr_agg.group_key) AS group_key, - coalesce(revenue_agg.revenue, - accurateCastOrNull(0, - 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, - accurateCastOrNull(0, - 'Decimal64(10)')) AS mrr - FROM ( - SELECT arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - WHERE notEmpty(group_key) - GROUP BY group_key) AS revenue_agg - FULL OUTER JOIN ( - SELECT customer_to_group.group_key AS group_key, - sum(coalesce(mrr_by_customer.mrr, - accurateCastOrNull(0, - 'Decimal64(10)'))) AS mrr - FROM ( - SELECT DISTINCT revenue_analytics_revenue_item.customer_id AS customer_id, - arrayJoin([revenue_analytics_revenue_item.group_0_key, revenue_analytics_revenue_item.group_1_key, revenue_analytics_revenue_item.group_2_key, revenue_analytics_revenue_item.group_3_key, revenue_analytics_revenue_item.group_4_key]) AS group_key - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - WHERE notEmpty(group_key)) AS customer_to_group - LEFT JOIN ( - SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM ( - SELECT union.source_label AS source_label, - union.customer_id AS customer_id, - union.subscription_id AS subscription_id, - argMax(union.amount, - union.timestamp) AS mrr - FROM ( - SELECT revenue_item.source_label AS source_label, - revenue_item.customer_id AS customer_id, - revenue_item.subscription_id AS subscription_id, - toStartOfMonth(toTimeZone(revenue_item.timestamp, - 'UTC')) AS timestamp, - sum(revenue_item.amount) AS amount - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, - isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'))) - GROUP BY revenue_item.source_label, - revenue_item.customer_id, - revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL - SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, - toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, - 'UTC') AS timestamp, - accurateCastOrNull(0, - 'Decimal64(10)') AS amount - FROM ( - SELECT subscription_id AS id, - 'revenue_analytics.events.purchase' AS source_label, - NULL AS plan_id, - product_id AS product_id, - toString(person_id) AS customer_id, - NULL AS status, - min_timestamp AS started_at, - if(greater(max_timestamp_plus_dropoff_days, - today()), NULL, - max_timestamp_plus_dropoff_days) AS ended_at, - NULL AS metadata - FROM ( - SELECT events__person.id AS person_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - NULL AS product_id, - min(toTimeZone(events.timestamp, - 'UTC')) AS min_timestamp, - max(toTimeZone(events.timestamp, - 'UTC')) AS max_timestamp, - addDays(max_timestamp, - 45.0) AS max_timestamp_plus_dropoff_days - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - LEFT JOIN ( - SELECT person.id AS id - FROM person - WHERE equals(person.team_id, - 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, - person.version), 0), less(argMax(toTimeZone(person.created_at, - 'UTC'), person.version), plus(now64(6, - 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id), events__person.id) - WHERE and(equals(events.team_id, - 99999), and(1, - isNotNull(subscription_id))) - GROUP BY subscription_id, - person_id) - ORDER BY started_at DESC) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` - WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, - customer_id, - subscription_id - ORDER BY customer_id ASC, - subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_by_customer ON equals(customer_to_group.customer_id, - mrr_by_customer.customer_id) - GROUP BY group_key) AS mrr_agg ON equals(revenue_agg.group_key, - mrr_agg.group_key)) AS groups_revenue_analytics - ORDER BY groups_revenue_analytics.group_key ASC - LIMIT 100 SETTINGS format_csv_allow_double_quotes=1, - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestGroupsRevenueAnalytics.test_query_revenue_analytics_table_sources ''' SELECT groups_revenue_analytics.group_key AS group_key, diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_persons.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_persons.ambr index 5e51b36b500f..f6476998a350 100644 --- a/posthog/hogql/database/schema/test/__snapshots__/test_persons.ambr +++ b/posthog/hogql/database/schema/test/__snapshots__/test_persons.ambr @@ -29,36 +29,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestArgMaxNonNullableSimplification.test_event_person_override_person_id_is_simplified[new_events_schema] - ''' - SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id - FROM - (SELECT events.distinct_id AS distinct_id, - events.person_id AS person_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, '$pageview')) - LIMIT 100) AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestArgMaxNonNullableSimplification.test_non_nullable_columns_are_simplified ''' SELECT persons.id AS id, @@ -88,64 +58,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestArgMaxNonNullableSimplification.test_nullable_json_property_keeps_wrap_and_latest_null_wins - ''' - SELECT persons.properties___jsonprop AS jsonprop, - persons.properties___untouched AS untouched - FROM - (SELECT tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'jsonprop'), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___jsonprop, - tupleElement(argMax(tuple(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'untouched'), ''), 'null'), '^"|"$', '')), person.version), 1) AS properties___untouched, - person.id AS id - FROM person - WHERE and(equals(person.team_id, 99999), in(id, - (SELECT where_optimization.id AS id - FROM person AS where_optimization - WHERE and(equals(where_optimization.team_id, 99999), equals(where_optimization.id, toUUIDOrNull('00000000-0000-4000-8000-000000000000')))))) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons - WHERE equals(persons.id, toUUIDOrNull('00000000-0000-4000-8000-000000000000')) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestArgMaxNonNullableSimplification.test_nullable_materialized_property_keeps_wrap_and_latest_null_wins - ''' - SELECT persons.properties___matprop AS matprop - FROM - (SELECT tupleElement(argMax(tuple(person.pmat_matprop), person.version), 1) AS properties___matprop, - person.id AS id - FROM person - WHERE and(equals(person.team_id, 99999), in(id, - (SELECT where_optimization.id AS id - FROM person AS where_optimization - WHERE and(equals(where_optimization.team_id, 99999), equals(where_optimization.id, toUUIDOrNull('00000000-0000-4000-8000-000000000000')))))) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons - WHERE equals(persons.id, toUUIDOrNull('00000000-0000-4000-8000-000000000000')) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestArgMaxNonNullableSimplification.test_nullable_property_keeps_wrap_and_latest_null_wins_0_json ''' SELECT persons.properties___jsonprop AS jsonprop, @@ -243,43 +155,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonOptimization.test_joins_are_left_alone_for_now[new_events_schema] - ''' - SELECT events.uuid AS uuid - FROM events_json AS events - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS events__pdi___person_id, - argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, - person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 99999) - GROUP BY person_distinct_id2.distinct_id - HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__pdi ON equals(events.distinct_id, events__pdi.distinct_id) - INNER JOIN - (SELECT person.id AS id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$some_prop'), ''), 'null'), '^"|"$', '') AS `properties___$some_prop` - FROM person - WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version), - (SELECT person.id AS id, max(person.version) AS version - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__pdi__person ON equals(events__pdi.events__pdi___person_id, events__pdi__person.id) - WHERE and(equals(events.team_id, 99999), ifNull(equals(events__pdi__person.`properties___$some_prop`, 'something'), 0)) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestPersonOptimization.test_order_by_limit_transferred ''' SELECT persons.id AS id, diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.ambr index 2a53ea28c1f6..b199ab86e36c 100644 --- a/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.ambr +++ b/posthog/hogql/database/schema/test/__snapshots__/test_persons_revenue_analytics.ambr @@ -210,217 +210,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalytics.test_get_revenue_for_events[new_events_schema] - ''' - SELECT persons__revenue_analytics.revenue AS revenue, - persons__revenue_analytics.revenue AS `$virt_revenue` - FROM - (SELECT argMax(person.id, person.version) AS persons___id, - person.id AS id - FROM person - WHERE and(equals(person.team_id, 99999), in(id, - (SELECT where_optimization.id AS id - FROM person AS where_optimization - WHERE and(equals(where_optimization.team_id, 99999), equals(where_optimization.id, '00000000-0000-0000-0000-000000000000'))))) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons - LEFT JOIN - (SELECT 99999 AS team_id, - person_id AS person_id, - sum(revenue) AS revenue, - sum(mrr) AS mrr - FROM - (SELECT 99999 AS team_id, - revenue_analytics_customer.id AS person_id, - coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM - (SELECT toString(persons.id) AS id, - 'revenue_analytics.events.purchase' AS source_label, - persons.created_at AS timestamp, - persons.properties___name AS name, - persons.properties___email AS email, - persons.properties___phone AS phone, - persons.properties___address AS address, - persons.properties___metadata AS metadata, - persons.`properties___$geoip_country_name` AS country, - formatDateTime(toStartOfMonth(persons.created_at), '%Y-%m') AS cohort, - NULL AS initial_coupon, - NULL AS initial_coupon_id - FROM - (SELECT person.id AS id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___name, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'phone'), ''), 'null'), '^"|"$', '') AS properties___phone, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'address'), ''), 'null'), '^"|"$', '') AS properties___address, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'metadata'), ''), 'null'), '^"|"$', '') AS properties___metadata, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$geoip_country_name'), ''), 'null'), '^"|"$', '') AS `properties___$geoip_country_name`, - toTimeZone(person.created_at, 'UTC') AS created_at - 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 persons - INNER JOIN - (SELECT DISTINCT events__person.id AS person_id - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - LEFT JOIN - (SELECT person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE equals(events.team_id, 99999)) AS events ON equals(persons.id, events.person_id) - ORDER BY persons.created_at DESC) AS revenue_analytics_customer - LEFT JOIN - (SELECT revenue_analytics_revenue_item.customer_id AS customer_id, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM - (SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, 'UTC') AS timestamp, - timestamp AS created_at, - 0 AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - NULL AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN - (SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM - (SELECT union.source_label AS source_label, - union.customer_id AS customer_id, - union.subscription_id AS subscription_id, - argMax(union.amount, union.timestamp) AS mrr - FROM - (SELECT revenue_item.source_label AS source_label, - revenue_item.customer_id AS customer_id, - revenue_item.subscription_id AS subscription_id, - toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, - sum(revenue_item.amount) AS amount - FROM - (SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, 'UTC') AS timestamp, - timestamp AS created_at, - 0 AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - NULL AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - GROUP BY revenue_item.source_label, - revenue_item.customer_id, - revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, - toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, 'UTC') AS timestamp, - accurateCastOrNull(0, 'Decimal64(10)') AS amount - FROM - (SELECT '' AS id, - '' AS source_label, - '' AS plan_id, - '' AS product_id, - '' AS customer_id, - '' AS status, - toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS started_at, - toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS ended_at, - '' AS metadata - WHERE 0) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` - WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, - customer_id, - subscription_id - ORDER BY customer_id ASC, - subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS persons__revenue_analytics ON equals(toString(persons.persons___id), toString(persons__revenue_analytics.person_id)) - WHERE equals(persons.id, '00000000-0000-0000-0000-000000000000') - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestPersonsRevenueAnalytics.test_get_revenue_for_schema_source_for_customer_with_multiple_distinct_ids ''' SELECT persons.id AS id, @@ -2155,396 +1944,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalytics.test_query_revenue_analytics_table_events[new_events_schema] - ''' - SELECT persons_revenue_analytics.person_id AS person_id, - persons_revenue_analytics.revenue AS revenue, - persons_revenue_analytics.mrr AS mrr - FROM ( - SELECT 99999 AS team_id, - person_id AS person_id, - sum(revenue) AS revenue, - sum(mrr) AS mrr - FROM ( - SELECT 99999 AS team_id, - revenue_analytics_customer.id AS person_id, - coalesce(revenue_agg.revenue, - accurateCastOrNull(0, - 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, - accurateCastOrNull(0, - 'Decimal64(10)')) AS mrr - FROM ( - SELECT toString(persons.id) AS id, - 'revenue_analytics.events.purchase' AS source_label, - persons.created_at AS timestamp, - persons.properties___name AS name, - persons.properties___email AS email, - persons.properties___phone AS phone, - persons.properties___address AS address, - persons.properties___metadata AS metadata, - persons.`properties___$geoip_country_name` AS country, - formatDateTime(toStartOfMonth(persons.created_at), '%Y-%m') AS cohort, - NULL AS initial_coupon, - NULL AS initial_coupon_id - FROM ( - SELECT person.id AS id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'name'), ''), 'null'), '^"|"$', - '') AS properties___name, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'email'), ''), 'null'), '^"|"$', - '') AS properties___email, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'phone'), ''), 'null'), '^"|"$', - '') AS properties___phone, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'address'), ''), 'null'), '^"|"$', - '') AS properties___address, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'metadata'), ''), 'null'), '^"|"$', - '') AS properties___metadata, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - '$geoip_country_name'), ''), 'null'), '^"|"$', - '') AS `properties___$geoip_country_name`, - toTimeZone(person.created_at, - 'UTC') AS created_at - 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 persons - INNER JOIN ( - SELECT DISTINCT events__person.id AS person_id - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - LEFT JOIN ( - SELECT person.id AS id - FROM person - WHERE equals(person.team_id, - 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, - person.version), 0), less(argMax(toTimeZone(person.created_at, - 'UTC'), person.version), plus(now64(6, - 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id), events__person.id) - WHERE equals(events.team_id, - 99999)) AS events ON equals(persons.id, - events.person_id) - ORDER BY persons.created_at DESC) AS revenue_analytics_customer - LEFT JOIN ( - SELECT revenue_analytics_revenue_item.customer_id AS customer_id, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, - revenue_agg.customer_id) - LEFT JOIN ( - SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM ( - SELECT union.source_label AS source_label, - union.customer_id AS customer_id, - union.subscription_id AS subscription_id, - argMax(union.amount, - union.timestamp) AS mrr - FROM ( - SELECT revenue_item.source_label AS source_label, - revenue_item.customer_id AS customer_id, - revenue_item.subscription_id AS subscription_id, - toStartOfMonth(toTimeZone(revenue_item.timestamp, - 'UTC')) AS timestamp, - sum(revenue_item.amount) AS amount - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - isNotNull(if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id)))))) AS is_recurring, - NULL AS product_id, - toString(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id)) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, - isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'))) - GROUP BY revenue_item.source_label, - revenue_item.customer_id, - revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL - SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, - toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, - 'UTC') AS timestamp, - accurateCastOrNull(0, - 'Decimal64(10)') AS amount - FROM ( - SELECT subscription_id AS id, - 'revenue_analytics.events.purchase' AS source_label, - NULL AS plan_id, - product_id AS product_id, - toString(person_id) AS customer_id, - NULL AS status, - min_timestamp AS started_at, - if(greater(max_timestamp_plus_dropoff_days, - today()), NULL, - max_timestamp_plus_dropoff_days) AS ended_at, - NULL AS metadata - FROM ( - SELECT events__person.id AS person_id, - if(notEquals(toJSONString(events.properties.^subscription_id), '{}'), toJSONString(events.properties.^subscription_id), if(isNull(events.properties.subscription_id), NULL, - if(startsWith(dynamicType(events.properties.subscription_id), 'DateTime'), replaceOne(toString(events.properties.subscription_id), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.subscription_id), 'Array'), startsWith(dynamicType(events.properties.subscription_id), 'Map'), startsWith(dynamicType(events.properties.subscription_id), 'Tuple')), toJSONString(events.properties.subscription_id), toString(events.properties.subscription_id))))) AS subscription_id, - NULL AS product_id, - min(toTimeZone(events.timestamp, - 'UTC')) AS min_timestamp, - max(toTimeZone(events.timestamp, - 'UTC')) AS max_timestamp, - addDays(max_timestamp, - 45.0) AS max_timestamp_plus_dropoff_days - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, - person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, - 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, - person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, - events__override.distinct_id) - LEFT JOIN ( - SELECT person.id AS id - FROM person - WHERE equals(person.team_id, - 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, - person.version), 0), less(argMax(toTimeZone(person.created_at, - 'UTC'), person.version), plus(now64(6, - 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, - events.person_id), events__person.id) - WHERE and(equals(events.team_id, - 99999), and(1, - isNotNull(subscription_id))) - GROUP BY subscription_id, - person_id) - ORDER BY started_at DESC) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` - WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', - 6, - 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, - customer_id, - subscription_id - ORDER BY customer_id ASC, - subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, - mrr_agg.customer_id)) - GROUP BY person_id) AS persons_revenue_analytics - ORDER BY persons_revenue_analytics.person_id ASC - LIMIT 100 SETTINGS format_csv_allow_double_quotes=1, - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalytics.test_query_revenue_analytics_table_sources +# name: TestPersonsRevenueAnalytics.test_query_revenue_analytics_table_sources ''' SELECT persons_revenue_analytics.person_id AS person_id, persons_revenue_analytics.revenue AS revenue, @@ -3421,137 +2821,6 @@ 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: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_0_disabled[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, arrayMap(i -> if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', i), breakdown_value) AS breakdown_value - FROM ( - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC')), toIntervalDay(1)))), 1))) AS date, 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 sum(total) AS count, day_start AS day_start, [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM ( - SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(leftUTF8(toString(e__pdi__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e - INNER JOIN ( - SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 99999) - GROUP BY person_distinct_id2.distinct_id - HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - LEFT JOIN ( - SELECT argMax(person.id, person.version) AS e__pdi__person___id, person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.e__pdi__person___id) - LEFT JOIN ( - SELECT 99999 AS team_id, person_id AS person_id, sum(revenue) AS revenue, sum(mrr) AS mrr - FROM ( - SELECT 99999 AS team_id, revenue_analytics_customer.id AS person_id, coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM ( - SELECT toString(persons.id) AS id, 'revenue_analytics.events.purchase' AS source_label, persons.created_at AS timestamp, persons.properties___name AS name, persons.properties___email AS email, persons.properties___phone AS phone, persons.properties___address AS address, persons.properties___metadata AS metadata, persons.`properties___$geoip_country_name` AS country, formatDateTime(toStartOfMonth(persons.created_at), '%Y-%m') AS cohort, NULL AS initial_coupon, NULL AS initial_coupon_id - FROM ( - SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___name, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'phone'), ''), 'null'), '^"|"$', '') AS properties___phone, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'address'), ''), 'null'), '^"|"$', '') AS properties___address, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'metadata'), ''), 'null'), '^"|"$', '') AS properties___metadata, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$geoip_country_name'), ''), 'null'), '^"|"$', '') AS `properties___$geoip_country_name`, toTimeZone(person.created_at, 'UTC') AS created_at - 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 persons - INNER JOIN ( - SELECT DISTINCT events__pdi__person.id AS person_id - FROM events_json AS events - INNER JOIN ( - SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS events__pdi___person_id, argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 99999) - GROUP BY person_distinct_id2.distinct_id - HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__pdi ON equals(events.distinct_id, events__pdi.distinct_id) - LEFT JOIN ( - SELECT person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__pdi__person ON equals(events__pdi.events__pdi___person_id, events__pdi__person.id) - WHERE equals(events.team_id, 99999)) AS events ON equals(persons.id, events.person_id) - ORDER BY persons.created_at DESC) AS revenue_analytics_customer - LEFT JOIN ( - SELECT revenue_analytics_revenue_item.customer_id AS customer_id, sum(revenue_analytics_revenue_item.amount) AS revenue - FROM ( - SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(events__pdi.person_id) AS customer_id, events.`$group_0` AS group_0_key, events.`$group_1` AS group_1_key, events.`$group_2` AS group_2_key, events.`$group_3` AS group_3_key, events.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - INNER JOIN ( - SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 99999) - GROUP BY person_distinct_id2.distinct_id - HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__pdi ON equals(events.distinct_id, events__pdi.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN ( - SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM ( - SELECT union.source_label AS source_label, union.customer_id AS customer_id, union.subscription_id AS subscription_id, argMax(union.amount, union.timestamp) AS mrr - FROM ( - SELECT revenue_item.source_label AS source_label, revenue_item.customer_id AS customer_id, revenue_item.subscription_id AS subscription_id, toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, sum(revenue_item.amount) AS amount - FROM ( - SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(events__pdi.person_id) AS customer_id, events.`$group_0` AS group_0_key, events.`$group_1` AS group_1_key, events.`$group_2` AS group_2_key, events.`$group_3` AS group_3_key, events.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - INNER JOIN ( - SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 99999) - GROUP BY person_distinct_id2.distinct_id - HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__pdi ON equals(events.distinct_id, events__pdi.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('2025-05-30 00:00:00.000000', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('2025-05-30 00:00:00.000000', 6, 'UTC'))) - GROUP BY revenue_item.source_label, revenue_item.customer_id, revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL - SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, 'UTC') AS timestamp, accurateCastOrNull(0, 'Decimal64(10)') AS amount - FROM ( - SELECT '' AS id, '' AS source_label, '' AS plan_id, '' AS product_id, '' AS customer_id, '' AS status, toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS started_at, toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS ended_at, '' AS metadata - WHERE 0) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('2025-05-30 00:00:00.000000', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('2025-05-30 00:00:00.000000', 6, 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, customer_id, subscription_id - ORDER BY customer_id ASC, subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__pdi__person__revenue_analytics ON equals(toString(e__pdi__person.e__pdi__person___id), toString(e__pdi__person__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) - GROUP BY day_start, breakdown_value_1) - GROUP BY day_start, breakdown_value_1 - ORDER BY day_start ASC, breakdown_value ASC) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC) - WHERE arrayExists(x -> isNotNull(x), breakdown_value) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 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: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_0_disabled[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events ''' SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp @@ -3773,376 +3042,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events[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, - arrayMap(i -> if(ifNull(greaterOrEquals(row_number, - 25), 0), '$$_posthog_breakdown_other_$$', - i), breakdown_value) AS breakdown_value - FROM ( - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', - 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, - plus(coalesce(dateDiff('day', - toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', - 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', - 'UTC')), toIntervalDay(1)))), 1))) AS date, - 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 sum(total) AS count, - day_start AS day_start, - [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM ( - SELECT count() AS total, - toStartOfDay(toTimeZone(e.timestamp, - 'UTC')) AS day_start, - ifNull(nullIf(leftUTF8(toString(e__poe__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e - LEFT JOIN ( - SELECT 99999 AS team_id, - person_id AS person_id, - sum(revenue) AS revenue, - sum(mrr) AS mrr - FROM ( - SELECT 99999 AS team_id, - revenue_analytics_customer.id AS person_id, - coalesce(revenue_agg.revenue, - accurateCastOrNull(0, - 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, - accurateCastOrNull(0, - 'Decimal64(10)')) AS mrr - FROM ( - SELECT toString(persons.id) AS id, - 'revenue_analytics.events.purchase' AS source_label, - persons.created_at AS timestamp, - persons.properties___name AS name, - persons.properties___email AS email, - persons.properties___phone AS phone, - persons.properties___address AS address, - persons.properties___metadata AS metadata, - persons.`properties___$geoip_country_name` AS country, - formatDateTime(toStartOfMonth(persons.created_at), '%Y-%m') AS cohort, - NULL AS initial_coupon, - NULL AS initial_coupon_id - FROM ( - SELECT person.id AS id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'name'), ''), 'null'), '^"|"$', - '') AS properties___name, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'email'), ''), 'null'), '^"|"$', - '') AS properties___email, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'phone'), ''), 'null'), '^"|"$', - '') AS properties___phone, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'address'), ''), 'null'), '^"|"$', - '') AS properties___address, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - 'metadata'), ''), 'null'), '^"|"$', - '') AS properties___metadata, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, - '$geoip_country_name'), ''), 'null'), '^"|"$', - '') AS `properties___$geoip_country_name`, - toTimeZone(person.created_at, - 'UTC') AS created_at - 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 persons - INNER JOIN ( - SELECT DISTINCT events.person_id AS person_id - FROM events_json AS events - WHERE equals(events.team_id, - 99999)) AS events ON equals(persons.id, - events.person_id) - ORDER BY persons.created_at DESC) AS revenue_analytics_customer - LEFT JOIN ( - SELECT revenue_analytics_revenue_item.customer_id AS customer_id, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - 0 AS is_recurring, - NULL AS product_id, - toString(events.person_id) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - NULL AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, - revenue_agg.customer_id) - LEFT JOIN ( - SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM ( - SELECT union.source_label AS source_label, - union.customer_id AS customer_id, - union.subscription_id AS subscription_id, - argMax(union.amount, - union.timestamp) AS mrr - FROM ( - SELECT revenue_item.source_label AS source_label, - revenue_item.customer_id AS customer_id, - revenue_item.subscription_id AS subscription_id, - toStartOfMonth(toTimeZone(revenue_item.timestamp, - 'UTC')) AS timestamp, - sum(revenue_item.amount) AS amount - FROM ( - SELECT toString(events.uuid) AS id, - toString(events.uuid) AS invoice_item_id, - 'revenue_analytics.events.purchase' AS source_label, - toTimeZone(events.timestamp, - 'UTC') AS timestamp, - timestamp AS created_at, - 0 AS is_recurring, - NULL AS product_id, - toString(events.person_id) AS customer_id, - events.`$group_0` AS group_0_key, - events.`$group_1` AS group_1_key, - events.`$group_2` AS group_2_key, - events.`$group_3` AS group_3_key, - events.`$group_4` AS group_4_key, - NULL AS invoice_id, - NULL AS subscription_id, - toString(events.`$session_id`) AS session_id, - events.event AS event_name, - NULL AS coupon, - coupon AS coupon_id, - 'USD' AS original_currency, - accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, - if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', - 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, - in(original_currency, - ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, - if(enable_currency_aware_divider, - accurateCastOrNull(1, - 'Decimal64(10)'), accurateCastOrNull(100, - 'Decimal64(10)')) AS currency_aware_divider, - divideDecimal(original_amount, - currency_aware_divider) AS currency_aware_amount, - 'USD' AS currency, - if(isNull('USD'), accurateCastOrNull(currency_aware_amount, - 'Decimal64(10)'), if(equals('USD', - 'USD'), toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(0, - 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, - 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)) = 0, - toDecimal128(1, - 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, - 'rate', - 'USD', - toDate(toTimeZone(events.timestamp, - 'UTC')), toDecimal64(0, - 10)))))) AS amount - FROM events_json AS events - WHERE and(equals(events.team_id, - 99999), and(equals(events.event, - 'purchase'), 1, - isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, - isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('2025-05-30 00:00:00.000000', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('2025-05-30 00:00:00.000000', - 6, - 'UTC'))) - GROUP BY revenue_item.source_label, - revenue_item.customer_id, - revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL - SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, - `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, - toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, - 'UTC') AS timestamp, - accurateCastOrNull(0, - 'Decimal64(10)') AS amount - FROM ( - SELECT '' AS id, - '' AS source_label, - '' AS plan_id, - '' AS product_id, - '' AS customer_id, - '' AS status, - toDateTime64('1970-01-01 00:00:00.000000', - 6, - 'UTC') AS started_at, - toDateTime64('1970-01-01 00:00:00.000000', - 6, - 'UTC') AS ended_at, - '' AS metadata - WHERE 0) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('2025-05-30 00:00:00.000000', - 6, - 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('2025-05-30 00:00:00.000000', - 6, - 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, - customer_id, - subscription_id - ORDER BY customer_id ASC, - subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, - mrr_agg.customer_id)) - GROUP BY person_id) AS e__poe__revenue_analytics ON equals(toString(e.person_id), toString(e__poe__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, - 99999), greaterOrEquals(e.timestamp, - toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', - 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, - assumeNotNull(toDateTime('2025-05-30 23:59:59', - 'UTC'))), equals(e.event, - '$pageview')) - GROUP BY day_start, - breakdown_value_1) - GROUP BY day_start, - breakdown_value_1 - ORDER BY day_start ASC, - breakdown_value ASC) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, - '$$_posthog_breakdown_other_$$'), 2, - if(has(breakdown_value, - '$$_posthog_breakdown_null_$$'), 1, - 0)) ASC, arraySum(total) DESC, breakdown_value ASC) - WHERE arrayExists(x -> isNotNull(x), breakdown_value) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, - '$$_posthog_breakdown_other_$$'), 2, - if(has(breakdown_value, - '$$_posthog_breakdown_null_$$'), 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: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_2_person_id_override_properties_on_events ''' SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp @@ -4262,7 +3161,27 @@ 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: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_2_person_id_override_properties_on_events[new_events_schema.1] +# name: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_3_person_id_override_properties_joined + ''' + SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp + FROM events + WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) + ORDER BY toTimeZone(events.timestamp, 'UTC') ASC + LIMIT 1 SETTINGS readonly=2, + max_execution_time=60, + allow_experimental_object_type=1, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, + max_bytes_before_external_group_by=0, + transform_null_in=1, + optimize_min_equality_disjunction_chain_length=4294967295, + optimize_rewrite_aggregate_function_with_if=0, + optimize_min_inequality_conjunction_chain_length=4294967295, + allow_experimental_join_condition=1, + use_hive_partitioning=0 + ''' +# --- +# name: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_3_person_id_override_properties_joined.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, arrayMap(i -> if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', i), breakdown_value) AS breakdown_value FROM ( @@ -4271,8 +3190,8 @@ FROM ( SELECT sum(total) AS count, day_start AS day_start, [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value FROM ( - SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(leftUTF8(toString(e__poe__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e + SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(leftUTF8(toString(e__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 + 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 @@ -4280,6 +3199,12 @@ GROUP BY person_distinct_id_overrides.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 argMax(person.id, person.version) AS e__person___id, person.id AS id + FROM person + WHERE equals(person.team_id, 99999) + GROUP BY person.id + HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.e__person___id) + LEFT JOIN ( SELECT 99999 AS team_id, person_id AS person_id, sum(revenue) AS revenue, sum(mrr) AS mrr FROM ( SELECT 99999 AS team_id, revenue_analytics_customer.id AS person_id, coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr @@ -4294,153 +3219,8 @@ 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 persons INNER JOIN ( - SELECT DISTINCT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE equals(events.team_id, 99999)) AS events ON equals(persons.id, events.person_id) - ORDER BY persons.created_at DESC) AS revenue_analytics_customer - LEFT JOIN ( - SELECT revenue_analytics_revenue_item.customer_id AS customer_id, sum(revenue_analytics_revenue_item.amount) AS revenue - FROM ( - SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.`$group_0` AS group_0_key, events.`$group_1` AS group_1_key, events.`$group_2` AS group_2_key, events.`$group_3` AS group_3_key, events.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN ( - SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM ( - SELECT union.source_label AS source_label, union.customer_id AS customer_id, union.subscription_id AS subscription_id, argMax(union.amount, union.timestamp) AS mrr - FROM ( - SELECT revenue_item.source_label AS source_label, revenue_item.customer_id AS customer_id, revenue_item.subscription_id AS subscription_id, toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, sum(revenue_item.amount) AS amount - FROM ( - SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.`$group_0` AS group_0_key, events.`$group_1` AS group_1_key, events.`$group_2` AS group_2_key, events.`$group_3` AS group_3_key, events.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - GROUP BY revenue_item.source_label, revenue_item.customer_id, revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL - SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, 'UTC') AS timestamp, accurateCastOrNull(0, 'Decimal64(10)') AS amount - FROM ( - SELECT '' AS id, '' AS source_label, '' AS plan_id, '' AS product_id, '' AS customer_id, '' AS status, toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS started_at, toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS ended_at, '' AS metadata - WHERE 0) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, customer_id, subscription_id - ORDER BY customer_id ASC, subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__poe__revenue_analytics ON equals(toString(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)), toString(e__poe__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) - GROUP BY day_start, breakdown_value_1) - GROUP BY day_start, breakdown_value_1 - ORDER BY day_start ASC, breakdown_value ASC) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC) - WHERE arrayExists(x -> isNotNull(x), breakdown_value) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 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: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_2_person_id_override_properties_on_events[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_3_person_id_override_properties_joined - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_3_person_id_override_properties_joined.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, arrayMap(i -> if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', i), breakdown_value) AS breakdown_value - FROM ( - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC')), toIntervalDay(1)))), 1))) AS date, 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 sum(total) AS count, day_start AS day_start, [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM ( - SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(leftUTF8(toString(e__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - 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 argMax(person.id, person.version) AS e__person___id, person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.e__person___id) - LEFT JOIN ( - SELECT 99999 AS team_id, person_id AS person_id, sum(revenue) AS revenue, sum(mrr) AS mrr - FROM ( - SELECT 99999 AS team_id, revenue_analytics_customer.id AS person_id, coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM ( - SELECT toString(persons.id) AS id, 'revenue_analytics.events.purchase' AS source_label, persons.created_at AS timestamp, persons.properties___name AS name, persons.properties___email AS email, persons.properties___phone AS phone, persons.properties___address AS address, persons.properties___metadata AS metadata, persons.`properties___$geoip_country_name` AS country, formatDateTime(toStartOfMonth(persons.created_at), '%Y-%m') AS cohort, NULL AS initial_coupon, NULL AS initial_coupon_id - FROM ( - SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___name, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'phone'), ''), 'null'), '^"|"$', '') AS properties___phone, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'address'), ''), 'null'), '^"|"$', '') AS properties___address, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'metadata'), ''), 'null'), '^"|"$', '') AS properties___metadata, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$geoip_country_name'), ''), 'null'), '^"|"$', '') AS `properties___$geoip_country_name`, toTimeZone(person.created_at, 'UTC') AS created_at - 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 persons - INNER JOIN ( - SELECT DISTINCT events__person.id AS person_id - FROM events + SELECT DISTINCT events__person.id AS person_id + FROM events LEFT OUTER JOIN ( SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides @@ -4512,138 +3292,7 @@ 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: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_3_person_id_override_properties_joined[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, arrayMap(i -> if(ifNull(greaterOrEquals(row_number, 25), 0), '$$_posthog_breakdown_other_$$', i), breakdown_value) AS breakdown_value - FROM ( - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC')), toIntervalDay(1)))), 1))) AS date, 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 sum(total) AS count, day_start AS day_start, [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM ( - SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(leftUTF8(toString(e__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.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 argMax(person.id, person.version) AS e__person___id, person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.e__person___id) - LEFT JOIN ( - SELECT 99999 AS team_id, person_id AS person_id, sum(revenue) AS revenue, sum(mrr) AS mrr - FROM ( - SELECT 99999 AS team_id, revenue_analytics_customer.id AS person_id, coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM ( - SELECT toString(persons.id) AS id, 'revenue_analytics.events.purchase' AS source_label, persons.created_at AS timestamp, persons.properties___name AS name, persons.properties___email AS email, persons.properties___phone AS phone, persons.properties___address AS address, persons.properties___metadata AS metadata, persons.`properties___$geoip_country_name` AS country, formatDateTime(toStartOfMonth(persons.created_at), '%Y-%m') AS cohort, NULL AS initial_coupon, NULL AS initial_coupon_id - FROM ( - SELECT person.id AS id, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'name'), ''), 'null'), '^"|"$', '') AS properties___name, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'phone'), ''), 'null'), '^"|"$', '') AS properties___phone, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'address'), ''), 'null'), '^"|"$', '') AS properties___address, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'metadata'), ''), 'null'), '^"|"$', '') AS properties___metadata, replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, '$geoip_country_name'), ''), 'null'), '^"|"$', '') AS `properties___$geoip_country_name`, toTimeZone(person.created_at, 'UTC') AS created_at - 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 persons - INNER JOIN ( - SELECT DISTINCT events__person.id AS person_id - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - LEFT JOIN ( - SELECT person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE equals(events.team_id, 99999)) AS events ON equals(persons.id, events.person_id) - ORDER BY persons.created_at DESC) AS revenue_analytics_customer - LEFT JOIN ( - SELECT revenue_analytics_revenue_item.customer_id AS customer_id, sum(revenue_analytics_revenue_item.amount) AS revenue - FROM ( - SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.`$group_0` AS group_0_key, events.`$group_1` AS group_1_key, events.`$group_2` AS group_2_key, events.`$group_3` AS group_3_key, events.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN ( - SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM ( - SELECT union.source_label AS source_label, union.customer_id AS customer_id, union.subscription_id AS subscription_id, argMax(union.amount, union.timestamp) AS mrr - FROM ( - SELECT revenue_item.source_label AS source_label, revenue_item.customer_id AS customer_id, revenue_item.subscription_id AS subscription_id, toStartOfMonth(toTimeZone(revenue_item.timestamp, 'UTC')) AS timestamp, sum(revenue_item.amount) AS amount - FROM ( - SELECT toString(events.uuid) AS id, toString(events.uuid) AS invoice_item_id, 'revenue_analytics.events.purchase' AS source_label, toTimeZone(events.timestamp, 'UTC') AS timestamp, timestamp AS created_at, 0 AS is_recurring, NULL AS product_id, toString(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS customer_id, events.`$group_0` AS group_0_key, events.`$group_1` AS group_1_key, events.`$group_2` AS group_2_key, events.`$group_3` AS group_3_key, events.`$group_4` AS group_4_key, NULL AS invoice_id, NULL AS subscription_id, toString(events.`$session_id`) AS session_id, events.event AS event_name, NULL AS coupon, coupon AS coupon_id, 'USD' AS original_currency, accurateCastOrNull(if(notEquals(toJSONString(events.properties.^revenue), '{}'), toJSONString(events.properties.^revenue), if(isNull(events.properties.revenue), NULL, if(startsWith(dynamicType(events.properties.revenue), 'DateTime'), replaceOne(toString(events.properties.revenue), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.revenue), 'Array'), startsWith(dynamicType(events.properties.revenue), 'Map'), startsWith(dynamicType(events.properties.revenue), 'Tuple')), toJSONString(events.properties.revenue), toString(events.properties.revenue))))), 'Decimal64(10)') AS original_amount, in(original_currency, ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF']) AS enable_currency_aware_divider, if(enable_currency_aware_divider, accurateCastOrNull(1, 'Decimal64(10)'), accurateCastOrNull(100, 'Decimal64(10)')) AS currency_aware_divider, divideDecimal(original_amount, currency_aware_divider) AS currency_aware_amount, 'USD' AS currency, if(isNull('USD'), accurateCastOrNull(currency_aware_amount, 'Decimal64(10)'), if(equals('USD', 'USD'), toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(0, 10), multiplyDecimal(divideDecimal(toDecimal128(currency_aware_amount, 10), if(dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)) = 0, toDecimal128(1, 10), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))), dictGetOrDefault(`posthog_test`.`exchange_rate_dict`, 'rate', 'USD', toDate(toTimeZone(events.timestamp, 'UTC')), toDecimal64(0, 10)))))) AS amount - FROM events_json AS events - LEFT OUTER JOIN ( - SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), and(equals(events.event, 'purchase'), 1, isNotNull(amount))) - ORDER BY timestamp DESC) AS revenue_item - WHERE and(revenue_item.is_recurring, isNotNull(revenue_item.subscription_id), greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - GROUP BY revenue_item.source_label, revenue_item.customer_id, revenue_item.subscription_id, timestamp - ORDER BY timestamp DESC - UNION ALL - SELECT `revenue_analytics.events.purchase.subscription_events_revenue_view`.source_label AS source_label, `revenue_analytics.events.purchase.subscription_events_revenue_view`.customer_id AS customer_id, `revenue_analytics.events.purchase.subscription_events_revenue_view`.id AS subscription_id, toTimeZone(`revenue_analytics.events.purchase.subscription_events_revenue_view`.ended_at, 'UTC') AS timestamp, accurateCastOrNull(0, 'Decimal64(10)') AS amount - FROM ( - SELECT '' AS id, '' AS source_label, '' AS plan_id, '' AS product_id, '' AS customer_id, '' AS status, toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS started_at, toDateTime64('1970-01-01 00:00:00.000000', 6, 'UTC') AS ended_at, '' AS metadata - WHERE 0) AS `revenue_analytics.events.purchase.subscription_events_revenue_view` WHERE and(greaterOrEquals(timestamp, toStartOfMonth(addDays(toDateTime64('explicit_redacted_timestamp', 6, 'UTC'), -60))), lessOrEquals(timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))) - ORDER BY timestamp DESC) AS - union - GROUP BY source_label, customer_id, subscription_id - ORDER BY customer_id ASC, subscription_id ASC) AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__person__revenue_analytics ON equals(toString(e__person.e__person___id), toString(e__person__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) - GROUP BY day_start, breakdown_value_1) - GROUP BY day_start, breakdown_value_1 - ORDER BY day_start ASC, breakdown_value ASC) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC) - WHERE arrayExists(x -> isNotNull(x), breakdown_value) - GROUP BY breakdown_value - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 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: TestPersonsRevenueAnalytics.test_virtual_property_in_trend_3_person_id_override_properties_joined[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_get_revenue_for_events +# name: TestPersonsRevenueAnalyticsManagedViewsets.test_get_revenue_for_events ''' SELECT persons__revenue_analytics.revenue AS revenue, persons__revenue_analytics.revenue AS `$virt_revenue` @@ -4946,455 +3595,22 @@ SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp FROM events WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_0_disabled.1 - ''' - WITH breakdown_series AS - (SELECT count AS count, - day_start AS day_start, - breakdown_value AS breakdown_value - FROM - (SELECT sum(total) AS count, - day_start AS day_start, - [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM - (SELECT count() AS total, - toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, - ifNull(nullIf(leftUTF8(toString(e__pdi__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id, - argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, - person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 99999) - GROUP BY person_distinct_id2.distinct_id - HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - INNER JOIN - (SELECT argMax(person.id, person.version) AS e__pdi__person___id, - person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.e__pdi__person___id) - LEFT JOIN - (SELECT 99999 AS team_id, - person_id AS person_id, - sum(revenue) AS revenue, - sum(mrr) AS mrr - FROM - (SELECT 99999 AS team_id, - revenue_analytics_customer.id AS person_id, - coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM - (SELECT * - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_customer_events_revenue_view/revenue_analytics.events.purchase.customer_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `name` Nullable(String), `email` Nullable(String), `phone` Nullable(String), `cohort` Nullable(String), `address` Nullable(String), `country` Nullable(String), `metadata` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `source_label` Nullable(String), `initial_coupon` Nullable(String), `initial_coupon_id` Nullable(String)')) AS revenue_analytics_customer - LEFT JOIN - (SELECT revenue_analytics_revenue_item.customer_id AS customer_id, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_revenue_item_events_revenue_view/revenue_analytics.events.purchase.revenue_item_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `amount` Nullable(Decimal64(10)), `coupon` Nullable(String), `currency` Nullable(String), `coupon_id` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `created_at` Nullable(DateTime64(6, \'UTC\')), `event_name` Nullable(String), `invoice_id` Nullable(String), `product_id` Nullable(String), `session_id` Nullable(String), `customer_id` Nullable(String), `group_0_key` Nullable(String), `group_1_key` Nullable(String), `group_2_key` Nullable(String), `group_3_key` Nullable(String), `group_4_key` Nullable(String), `is_recurring` Nullable(Boolean), `source_label` Nullable(String), `invoice_item_id` Nullable(String), `original_amount` Nullable(Decimal64(10)), `subscription_id` Nullable(String), `original_currency` Nullable(String), `currency_aware_amount` Nullable(Decimal64(10)), `currency_aware_divider` Nullable(Decimal64(10)), `enable_currency_aware_divider` Nullable(Boolean)') AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN - (SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_mrr_events_revenue_view/revenue_analytics.events.purchase.mrr_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`mrr` Nullable(Decimal64(10)), `customer_id` Nullable(String), `source_label` Nullable(String), `subscription_id` Nullable(String)') AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__pdi__person__revenue_analytics ON equals(toString(e__pdi__person.e__pdi__person___id), toString(e__pdi__person__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) - GROUP BY day_start, - breakdown_value_1) - GROUP BY day_start, - breakdown_value_1 - ORDER BY day_start ASC, - breakdown_value ASC)), - totals_per_breakdown AS - (SELECT breakdown_series.breakdown_value AS breakdown_value, - sum(breakdown_series.count) AS total_count_for_breakdown, - if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) AS ordering - FROM breakdown_series - GROUP BY breakdown_series.breakdown_value), - ranked_breakdown_totals AS - (SELECT totals_per_breakdown.breakdown_value AS breakdown_value, - totals_per_breakdown.ordering AS ordering, - totals_per_breakdown.total_count_for_breakdown AS total_count_for_breakdown, - row_number() OVER ( - ORDER BY totals_per_breakdown.ordering ASC, totals_per_breakdown.total_count_for_breakdown DESC, totals_per_breakdown.breakdown_value ASC) AS breakdown_rank - FROM totals_per_breakdown), - ranked_breakdown_values AS - (SELECT breakdown_series.count AS count, - toTimeZone(breakdown_series.day_start, 'UTC') AS day_start, - breakdown_series.breakdown_value AS breakdown_value, - ranked_breakdown_totals.ordering AS ordering, - ranked_breakdown_totals.breakdown_rank AS breakdown_rank - FROM breakdown_series - JOIN ranked_breakdown_totals ON equals(ranked_breakdown_totals.breakdown_value, breakdown_series.breakdown_value)), - top_n_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - ranked_breakdown_values.count AS value, - ranked_breakdown_values.breakdown_value AS breakdown_value - FROM ranked_breakdown_values - WHERE lessOrEquals(ranked_breakdown_values.breakdown_rank, 25)), - other_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - sum(ranked_breakdown_values.count) AS value, - ['$$_posthog_breakdown_other_$$'] AS breakdown_value - FROM ranked_breakdown_values - WHERE greater(ranked_breakdown_values.breakdown_rank, 25) - GROUP BY toTimeZone(ranked_breakdown_values.day_start, 'UTC')), - top_n_and_other_breakdown_values AS - (SELECT day_start AS day_start, - value AS value, - breakdown_value AS breakdown_value - FROM - (SELECT toTimeZone(top_n_breakdown_values.day_start, 'UTC') AS day_start, - top_n_breakdown_values.value AS value, - top_n_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_breakdown_values - UNION ALL SELECT toTimeZone(other_breakdown_values.day_start, 'UTC') AS day_start, - other_breakdown_values.value AS value, - other_breakdown_values.breakdown_value AS breakdown_value - FROM other_breakdown_values) - ORDER BY day_start ASC, - value ASC) - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC')), toIntervalDay(1)))), 1))) AS date, - arrayMap(d -> arraySum(arrayMap((v, dd) -> if(ifNull(equals(dd, d), isNull(dd) - and isNull(d)), v, 0), vals, days)), date) AS total, - breakdown_value AS breakdown_value - FROM - (SELECT groupArray(toTimeZone(top_n_and_other_breakdown_values.day_start, 'UTC')) AS days, - groupArray(top_n_and_other_breakdown_values.value) AS vals, - top_n_and_other_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_and_other_breakdown_values - GROUP BY top_n_and_other_breakdown_values.breakdown_value) - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC - LIMIT 50000 SETTINGS format_csv_allow_double_quotes=1, - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_0_disabled[new_events_schema.1] - ''' - WITH breakdown_series AS - (SELECT count AS count, - day_start AS day_start, - breakdown_value AS breakdown_value - FROM - (SELECT sum(total) AS count, - day_start AS day_start, - [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM - (SELECT count() AS total, - toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, - ifNull(nullIf(leftUTF8(toString(e__pdi__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e - INNER JOIN - (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id, - argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, - person_distinct_id2.distinct_id AS distinct_id - FROM person_distinct_id2 - WHERE equals(person_distinct_id2.team_id, 99999) - GROUP BY person_distinct_id2.distinct_id - HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) - INNER JOIN - (SELECT argMax(person.id, person.version) AS e__pdi__person___id, - person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.e__pdi__person___id) - LEFT JOIN - (SELECT 99999 AS team_id, - person_id AS person_id, - sum(revenue) AS revenue, - sum(mrr) AS mrr - FROM - (SELECT 99999 AS team_id, - revenue_analytics_customer.id AS person_id, - coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM - (SELECT * - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_customer_events_revenue_view/revenue_analytics.events.purchase.customer_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `name` Nullable(String), `email` Nullable(String), `phone` Nullable(String), `cohort` Nullable(String), `address` Nullable(String), `country` Nullable(String), `metadata` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `source_label` Nullable(String), `initial_coupon` Nullable(String), `initial_coupon_id` Nullable(String)')) AS revenue_analytics_customer - LEFT JOIN - (SELECT revenue_analytics_revenue_item.customer_id AS customer_id, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_revenue_item_events_revenue_view/revenue_analytics.events.purchase.revenue_item_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `amount` Nullable(Decimal64(10)), `coupon` Nullable(String), `currency` Nullable(String), `coupon_id` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `created_at` Nullable(DateTime64(6, \'UTC\')), `event_name` Nullable(String), `invoice_id` Nullable(String), `product_id` Nullable(String), `session_id` Nullable(String), `customer_id` Nullable(String), `group_0_key` Nullable(String), `group_1_key` Nullable(String), `group_2_key` Nullable(String), `group_3_key` Nullable(String), `group_4_key` Nullable(String), `is_recurring` Nullable(Boolean), `source_label` Nullable(String), `invoice_item_id` Nullable(String), `original_amount` Nullable(Decimal64(10)), `subscription_id` Nullable(String), `original_currency` Nullable(String), `currency_aware_amount` Nullable(Decimal64(10)), `currency_aware_divider` Nullable(Decimal64(10)), `enable_currency_aware_divider` Nullable(Boolean)') AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN - (SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_mrr_events_revenue_view/revenue_analytics.events.purchase.mrr_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`mrr` Nullable(Decimal64(10)), `customer_id` Nullable(String), `source_label` Nullable(String), `subscription_id` Nullable(String)') AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__pdi__person__revenue_analytics ON equals(toString(e__pdi__person.e__pdi__person___id), toString(e__pdi__person__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) - GROUP BY day_start, - breakdown_value_1) - GROUP BY day_start, - breakdown_value_1 - ORDER BY day_start ASC, - breakdown_value ASC)), - totals_per_breakdown AS - (SELECT breakdown_series.breakdown_value AS breakdown_value, - sum(breakdown_series.count) AS total_count_for_breakdown, - if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) AS ordering - FROM breakdown_series - GROUP BY breakdown_series.breakdown_value), - ranked_breakdown_totals AS - (SELECT totals_per_breakdown.breakdown_value AS breakdown_value, - totals_per_breakdown.ordering AS ordering, - totals_per_breakdown.total_count_for_breakdown AS total_count_for_breakdown, - row_number() OVER ( - ORDER BY totals_per_breakdown.ordering ASC, totals_per_breakdown.total_count_for_breakdown DESC, totals_per_breakdown.breakdown_value ASC) AS breakdown_rank - FROM totals_per_breakdown), - ranked_breakdown_values AS - (SELECT breakdown_series.count AS count, - toTimeZone(breakdown_series.day_start, 'UTC') AS day_start, - breakdown_series.breakdown_value AS breakdown_value, - ranked_breakdown_totals.ordering AS ordering, - ranked_breakdown_totals.breakdown_rank AS breakdown_rank - FROM breakdown_series - JOIN ranked_breakdown_totals ON equals(ranked_breakdown_totals.breakdown_value, breakdown_series.breakdown_value)), - top_n_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - ranked_breakdown_values.count AS value, - ranked_breakdown_values.breakdown_value AS breakdown_value - FROM ranked_breakdown_values - WHERE lessOrEquals(ranked_breakdown_values.breakdown_rank, 25)), - other_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - sum(ranked_breakdown_values.count) AS value, - ['$$_posthog_breakdown_other_$$'] AS breakdown_value - FROM ranked_breakdown_values - WHERE greater(ranked_breakdown_values.breakdown_rank, 25) - GROUP BY toTimeZone(ranked_breakdown_values.day_start, 'UTC')), - top_n_and_other_breakdown_values AS - (SELECT day_start AS day_start, - value AS value, - breakdown_value AS breakdown_value - FROM - (SELECT toTimeZone(top_n_breakdown_values.day_start, 'UTC') AS day_start, - top_n_breakdown_values.value AS value, - top_n_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_breakdown_values - UNION ALL SELECT toTimeZone(other_breakdown_values.day_start, 'UTC') AS day_start, - other_breakdown_values.value AS value, - other_breakdown_values.breakdown_value AS breakdown_value - FROM other_breakdown_values) - ORDER BY day_start ASC, - value ASC) - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC')), toIntervalDay(1)))), 1))) AS date, - arrayMap(d -> arraySum(arrayMap((v, dd) -> if(ifNull(equals(dd, d), isNull(dd) - and isNull(d)), v, 0), vals, days)), date) AS total, - breakdown_value AS breakdown_value - FROM - (SELECT groupArray(toTimeZone(top_n_and_other_breakdown_values.day_start, 'UTC')) AS days, - groupArray(top_n_and_other_breakdown_values.value) AS vals, - top_n_and_other_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_and_other_breakdown_values - GROUP BY top_n_and_other_breakdown_values.breakdown_value) - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC - LIMIT 50000 SETTINGS format_csv_allow_double_quotes=1, - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_0_disabled[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events.1 - ''' - WITH breakdown_series AS - (SELECT count AS count, - day_start AS day_start, - breakdown_value AS breakdown_value - FROM - (SELECT sum(total) AS count, - day_start AS day_start, - [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM - (SELECT count() AS total, - toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, - ifNull(nullIf(leftUTF8(toString(e__poe__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events AS e - LEFT JOIN - (SELECT 99999 AS team_id, - person_id AS person_id, - sum(revenue) AS revenue, - sum(mrr) AS mrr - FROM - (SELECT 99999 AS team_id, - revenue_analytics_customer.id AS person_id, - coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM - (SELECT * - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_customer_events_revenue_view/revenue_analytics.events.purchase.customer_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `name` Nullable(String), `email` Nullable(String), `phone` Nullable(String), `cohort` Nullable(String), `address` Nullable(String), `country` Nullable(String), `metadata` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `source_label` Nullable(String), `initial_coupon` Nullable(String), `initial_coupon_id` Nullable(String)')) AS revenue_analytics_customer - LEFT JOIN - (SELECT revenue_analytics_revenue_item.customer_id AS customer_id, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_revenue_item_events_revenue_view/revenue_analytics.events.purchase.revenue_item_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `amount` Nullable(Decimal64(10)), `coupon` Nullable(String), `currency` Nullable(String), `coupon_id` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `created_at` Nullable(DateTime64(6, \'UTC\')), `event_name` Nullable(String), `invoice_id` Nullable(String), `product_id` Nullable(String), `session_id` Nullable(String), `customer_id` Nullable(String), `group_0_key` Nullable(String), `group_1_key` Nullable(String), `group_2_key` Nullable(String), `group_3_key` Nullable(String), `group_4_key` Nullable(String), `is_recurring` Nullable(Boolean), `source_label` Nullable(String), `invoice_item_id` Nullable(String), `original_amount` Nullable(Decimal64(10)), `subscription_id` Nullable(String), `original_currency` Nullable(String), `currency_aware_amount` Nullable(Decimal64(10)), `currency_aware_divider` Nullable(Decimal64(10)), `enable_currency_aware_divider` Nullable(Boolean)') AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN - (SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_mrr_events_revenue_view/revenue_analytics.events.purchase.mrr_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`mrr` Nullable(Decimal64(10)), `customer_id` Nullable(String), `source_label` Nullable(String), `subscription_id` Nullable(String)') AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__poe__revenue_analytics ON equals(toString(e.person_id), toString(e__poe__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) - GROUP BY day_start, - breakdown_value_1) - GROUP BY day_start, - breakdown_value_1 - ORDER BY day_start ASC, - breakdown_value ASC)), - totals_per_breakdown AS - (SELECT breakdown_series.breakdown_value AS breakdown_value, - sum(breakdown_series.count) AS total_count_for_breakdown, - if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) AS ordering - FROM breakdown_series - GROUP BY breakdown_series.breakdown_value), - ranked_breakdown_totals AS - (SELECT totals_per_breakdown.breakdown_value AS breakdown_value, - totals_per_breakdown.ordering AS ordering, - totals_per_breakdown.total_count_for_breakdown AS total_count_for_breakdown, - row_number() OVER ( - ORDER BY totals_per_breakdown.ordering ASC, totals_per_breakdown.total_count_for_breakdown DESC, totals_per_breakdown.breakdown_value ASC) AS breakdown_rank - FROM totals_per_breakdown), - ranked_breakdown_values AS - (SELECT breakdown_series.count AS count, - toTimeZone(breakdown_series.day_start, 'UTC') AS day_start, - breakdown_series.breakdown_value AS breakdown_value, - ranked_breakdown_totals.ordering AS ordering, - ranked_breakdown_totals.breakdown_rank AS breakdown_rank - FROM breakdown_series - JOIN ranked_breakdown_totals ON equals(ranked_breakdown_totals.breakdown_value, breakdown_series.breakdown_value)), - top_n_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - ranked_breakdown_values.count AS value, - ranked_breakdown_values.breakdown_value AS breakdown_value - FROM ranked_breakdown_values - WHERE lessOrEquals(ranked_breakdown_values.breakdown_rank, 25)), - other_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - sum(ranked_breakdown_values.count) AS value, - ['$$_posthog_breakdown_other_$$'] AS breakdown_value - FROM ranked_breakdown_values - WHERE greater(ranked_breakdown_values.breakdown_rank, 25) - GROUP BY toTimeZone(ranked_breakdown_values.day_start, 'UTC')), - top_n_and_other_breakdown_values AS - (SELECT day_start AS day_start, - value AS value, - breakdown_value AS breakdown_value - FROM - (SELECT toTimeZone(top_n_breakdown_values.day_start, 'UTC') AS day_start, - top_n_breakdown_values.value AS value, - top_n_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_breakdown_values - UNION ALL SELECT toTimeZone(other_breakdown_values.day_start, 'UTC') AS day_start, - other_breakdown_values.value AS value, - other_breakdown_values.breakdown_value AS breakdown_value - FROM other_breakdown_values) - ORDER BY day_start ASC, - value ASC) - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC')), toIntervalDay(1)))), 1))) AS date, - arrayMap(d -> arraySum(arrayMap((v, dd) -> if(ifNull(equals(dd, d), isNull(dd) - and isNull(d)), v, 0), vals, days)), date) AS total, - breakdown_value AS breakdown_value - FROM - (SELECT groupArray(toTimeZone(top_n_and_other_breakdown_values.day_start, 'UTC')) AS days, - groupArray(top_n_and_other_breakdown_values.value) AS vals, - top_n_and_other_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_and_other_breakdown_values - GROUP BY top_n_and_other_breakdown_values.breakdown_value) - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC - LIMIT 50000 SETTINGS format_csv_allow_double_quotes=1, - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 + ORDER BY toTimeZone(events.timestamp, 'UTC') ASC + LIMIT 1 SETTINGS readonly=2, + max_execution_time=60, + allow_experimental_object_type=1, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, + max_bytes_before_external_group_by=0, + transform_null_in=1, + optimize_min_equality_disjunction_chain_length=4294967295, + optimize_rewrite_aggregate_function_with_if=0, + optimize_min_inequality_conjunction_chain_length=4294967295, + allow_experimental_join_condition=1, + use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events[new_events_schema.1] +# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_0_disabled.1 ''' WITH breakdown_series AS (SELECT count AS count, @@ -5407,8 +3623,23 @@ FROM (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, - ifNull(nullIf(leftUTF8(toString(e__poe__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e + ifNull(nullIf(leftUTF8(toString(e__pdi__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 + FROM events AS e + INNER JOIN + (SELECT argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS e__pdi___person_id, + argMax(person_distinct_id2.person_id, person_distinct_id2.version) AS person_id, + person_distinct_id2.distinct_id AS distinct_id + FROM person_distinct_id2 + WHERE equals(person_distinct_id2.team_id, 99999) + GROUP BY person_distinct_id2.distinct_id + HAVING equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0) SETTINGS optimize_aggregation_in_order=1) AS e__pdi ON equals(e.distinct_id, e__pdi.distinct_id) + INNER JOIN + (SELECT argMax(person.id, person.version) AS e__pdi__person___id, + person.id AS id + FROM person + WHERE equals(person.team_id, 99999) + GROUP BY person.id + HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__pdi__person ON equals(e__pdi.e__pdi___person_id, e__pdi__person.e__pdi__person___id) LEFT JOIN (SELECT 99999 AS team_id, person_id AS person_id, @@ -5432,7 +3663,7 @@ sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_mrr_events_revenue_view/revenue_analytics.events.purchase.mrr_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`mrr` Nullable(Decimal64(10)), `customer_id` Nullable(String), `source_label` Nullable(String), `subscription_id` Nullable(String)') AS `revenue_analytics.events.purchase.mrr_events_revenue_view` GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__poe__revenue_analytics ON equals(toString(e.person_id), toString(e__poe__revenue_analytics.person_id)) + GROUP BY person_id) AS e__pdi__person__revenue_analytics ON equals(toString(e__pdi__person.e__pdi__person___id), toString(e__pdi__person__revenue_analytics.person_id)) WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) GROUP BY day_start, breakdown_value_1) @@ -5515,27 +3746,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_2_person_id_override_properties_on_events +# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events ''' SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp FROM events @@ -5555,7 +3766,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_2_person_id_override_properties_on_events.1 +# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_1_person_id_no_override_properties_on_events.1 ''' WITH breakdown_series AS (SELECT count AS count, @@ -5570,13 +3781,6 @@ toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(leftUTF8(toString(e__poe__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 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 99999 AS team_id, person_id AS person_id, @@ -5600,7 +3804,7 @@ sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_mrr_events_revenue_view/revenue_analytics.events.purchase.mrr_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`mrr` Nullable(Decimal64(10)), `customer_id` Nullable(String), `source_label` Nullable(String), `subscription_id` Nullable(String)') AS `revenue_analytics.events.purchase.mrr_events_revenue_view` GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__poe__revenue_analytics ON equals(toString(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id)), toString(e__poe__revenue_analytics.person_id)) + GROUP BY person_id) AS e__poe__revenue_analytics ON equals(toString(e.person_id), toString(e__poe__revenue_analytics.person_id)) WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) GROUP BY day_start, breakdown_value_1) @@ -5683,7 +3887,27 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_2_person_id_override_properties_on_events[new_events_schema.1] +# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_2_person_id_override_properties_on_events + ''' + SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp + FROM events + WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) + ORDER BY toTimeZone(events.timestamp, 'UTC') ASC + LIMIT 1 SETTINGS readonly=2, + max_execution_time=60, + allow_experimental_object_type=1, + max_ast_elements=4000000, + max_expanded_ast_elements=4000000, + max_bytes_before_external_group_by=0, + transform_null_in=1, + optimize_min_equality_disjunction_chain_length=4294967295, + optimize_rewrite_aggregate_function_with_if=0, + optimize_min_inequality_conjunction_chain_length=4294967295, + allow_experimental_join_condition=1, + use_hive_partitioning=0 + ''' +# --- +# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_2_person_id_override_properties_on_events.1 ''' WITH breakdown_series AS (SELECT count AS count, @@ -5697,7 +3921,7 @@ (SELECT count() AS total, toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, ifNull(nullIf(leftUTF8(toString(e__poe__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e + 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 @@ -5811,26 +4035,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_2_person_id_override_properties_on_events[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_3_person_id_override_properties_joined ''' SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp @@ -5986,158 +4190,3 @@ use_hive_partitioning=0 ''' # --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_3_person_id_override_properties_joined[new_events_schema.1] - ''' - WITH breakdown_series AS - (SELECT count AS count, - day_start AS day_start, - breakdown_value AS breakdown_value - FROM - (SELECT sum(total) AS count, - day_start AS day_start, - [ifNull(toString(breakdown_value_1), '$$_posthog_breakdown_null_$$')] AS breakdown_value - FROM - (SELECT count() AS total, - toStartOfDay(toTimeZone(e.timestamp, 'UTC')) AS day_start, - ifNull(nullIf(leftUTF8(toString(e__person__revenue_analytics.revenue), 400), ''), '$$_posthog_breakdown_null_$$') AS breakdown_value_1 - FROM events_json AS e - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.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) - INNER JOIN - (SELECT argMax(person.id, person.version) AS e__person___id, - person.id AS id - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS e__person ON equals(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), e__person.e__person___id) - LEFT JOIN - (SELECT 99999 AS team_id, - person_id AS person_id, - sum(revenue) AS revenue, - sum(mrr) AS mrr - FROM - (SELECT 99999 AS team_id, - revenue_analytics_customer.id AS person_id, - coalesce(revenue_agg.revenue, accurateCastOrNull(0, 'Decimal64(10)')) AS revenue, - coalesce(mrr_agg.mrr, accurateCastOrNull(0, 'Decimal64(10)')) AS mrr - FROM - (SELECT * - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_customer_events_revenue_view/revenue_analytics.events.purchase.customer_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `name` Nullable(String), `email` Nullable(String), `phone` Nullable(String), `cohort` Nullable(String), `address` Nullable(String), `country` Nullable(String), `metadata` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `source_label` Nullable(String), `initial_coupon` Nullable(String), `initial_coupon_id` Nullable(String)')) AS revenue_analytics_customer - LEFT JOIN - (SELECT revenue_analytics_revenue_item.customer_id AS customer_id, - sum(revenue_analytics_revenue_item.amount) AS revenue - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_revenue_item_events_revenue_view/revenue_analytics.events.purchase.revenue_item_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`id` Nullable(String), `amount` Nullable(Decimal64(10)), `coupon` Nullable(String), `currency` Nullable(String), `coupon_id` Nullable(String), `timestamp` Nullable(DateTime64(6, \'UTC\')), `created_at` Nullable(DateTime64(6, \'UTC\')), `event_name` Nullable(String), `invoice_id` Nullable(String), `product_id` Nullable(String), `session_id` Nullable(String), `customer_id` Nullable(String), `group_0_key` Nullable(String), `group_1_key` Nullable(String), `group_2_key` Nullable(String), `group_3_key` Nullable(String), `group_4_key` Nullable(String), `is_recurring` Nullable(Boolean), `source_label` Nullable(String), `invoice_item_id` Nullable(String), `original_amount` Nullable(Decimal64(10)), `subscription_id` Nullable(String), `original_currency` Nullable(String), `currency_aware_amount` Nullable(Decimal64(10)), `currency_aware_divider` Nullable(Decimal64(10)), `enable_currency_aware_divider` Nullable(Boolean)') AS revenue_analytics_revenue_item - GROUP BY customer_id) AS revenue_agg ON equals(revenue_analytics_customer.id, revenue_agg.customer_id) - LEFT JOIN - (SELECT `revenue_analytics.events.purchase.mrr_events_revenue_view`.customer_id AS customer_id, - sum(`revenue_analytics.events.purchase.mrr_events_revenue_view`.mrr) AS mrr - FROM s3('http://host.docker.internal:19000/posthog/test_storage_bucket-revenue_analytics_events_purchase_mrr_events_revenue_view/revenue_analytics.events.purchase.mrr_events_revenue_view/*.csv', 'object_storage_root_user', 'object_storage_root_password', 'CSVWithNames', '`mrr` Nullable(Decimal64(10)), `customer_id` Nullable(String), `source_label` Nullable(String), `subscription_id` Nullable(String)') AS `revenue_analytics.events.purchase.mrr_events_revenue_view` - GROUP BY customer_id) AS mrr_agg ON equals(revenue_analytics_customer.id, mrr_agg.customer_id)) - GROUP BY person_id) AS e__person__revenue_analytics ON equals(toString(e__person.e__person___id), toString(e__person__revenue_analytics.person_id)) - WHERE and(equals(e.team_id, 99999), greaterOrEquals(e.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(e.timestamp, assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC'))), equals(e.event, '$pageview')) - GROUP BY day_start, - breakdown_value_1) - GROUP BY day_start, - breakdown_value_1 - ORDER BY day_start ASC, - breakdown_value ASC)), - totals_per_breakdown AS - (SELECT breakdown_series.breakdown_value AS breakdown_value, - sum(breakdown_series.count) AS total_count_for_breakdown, - if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_series.breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) AS ordering - FROM breakdown_series - GROUP BY breakdown_series.breakdown_value), - ranked_breakdown_totals AS - (SELECT totals_per_breakdown.breakdown_value AS breakdown_value, - totals_per_breakdown.ordering AS ordering, - totals_per_breakdown.total_count_for_breakdown AS total_count_for_breakdown, - row_number() OVER ( - ORDER BY totals_per_breakdown.ordering ASC, totals_per_breakdown.total_count_for_breakdown DESC, totals_per_breakdown.breakdown_value ASC) AS breakdown_rank - FROM totals_per_breakdown), - ranked_breakdown_values AS - (SELECT breakdown_series.count AS count, - toTimeZone(breakdown_series.day_start, 'UTC') AS day_start, - breakdown_series.breakdown_value AS breakdown_value, - ranked_breakdown_totals.ordering AS ordering, - ranked_breakdown_totals.breakdown_rank AS breakdown_rank - FROM breakdown_series - JOIN ranked_breakdown_totals ON equals(ranked_breakdown_totals.breakdown_value, breakdown_series.breakdown_value)), - top_n_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - ranked_breakdown_values.count AS value, - ranked_breakdown_values.breakdown_value AS breakdown_value - FROM ranked_breakdown_values - WHERE lessOrEquals(ranked_breakdown_values.breakdown_rank, 25)), - other_breakdown_values AS - (SELECT toTimeZone(ranked_breakdown_values.day_start, 'UTC') AS day_start, - sum(ranked_breakdown_values.count) AS value, - ['$$_posthog_breakdown_other_$$'] AS breakdown_value - FROM ranked_breakdown_values - WHERE greater(ranked_breakdown_values.breakdown_rank, 25) - GROUP BY toTimeZone(ranked_breakdown_values.day_start, 'UTC')), - top_n_and_other_breakdown_values AS - (SELECT day_start AS day_start, - value AS value, - breakdown_value AS breakdown_value - FROM - (SELECT toTimeZone(top_n_breakdown_values.day_start, 'UTC') AS day_start, - top_n_breakdown_values.value AS value, - top_n_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_breakdown_values - UNION ALL SELECT toTimeZone(other_breakdown_values.day_start, 'UTC') AS day_start, - other_breakdown_values.value AS value, - other_breakdown_values.breakdown_value AS breakdown_value - FROM other_breakdown_values) - ORDER BY day_start ASC, - value ASC) - SELECT arrayMap(number -> plus(toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(number)), range(0, plus(coalesce(dateDiff('day', toStartOfInterval(assumeNotNull(toDateTime('2025-05-29 00:00:00', 'UTC')), toIntervalDay(1)), toStartOfInterval(assumeNotNull(toDateTime('2025-05-30 23:59:59', 'UTC')), toIntervalDay(1)))), 1))) AS date, - arrayMap(d -> arraySum(arrayMap((v, dd) -> if(ifNull(equals(dd, d), isNull(dd) - and isNull(d)), v, 0), vals, days)), date) AS total, - breakdown_value AS breakdown_value - FROM - (SELECT groupArray(toTimeZone(top_n_and_other_breakdown_values.day_start, 'UTC')) AS days, - groupArray(top_n_and_other_breakdown_values.value) AS vals, - top_n_and_other_breakdown_values.breakdown_value AS breakdown_value - FROM top_n_and_other_breakdown_values - GROUP BY top_n_and_other_breakdown_values.breakdown_value) - ORDER BY if(has(breakdown_value, '$$_posthog_breakdown_other_$$'), 2, if(has(breakdown_value, '$$_posthog_breakdown_null_$$'), 1, 0)) ASC, arraySum(total) DESC, breakdown_value ASC - LIMIT 50000 SETTINGS format_csv_allow_double_quotes=1, - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestPersonsRevenueAnalyticsManagedViewsets.test_virtual_property_in_trend_3_person_id_override_properties_joined[new_events_schema] - ''' - SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), greater(events.timestamp, toDateTime64('1980-01-01 00:00:00.000000', 6, 'UTC')), equals(events.event, '$pageview')) - ORDER BY toTimeZone(events.timestamp, 'UTC') ASC - LIMIT 1 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr index ccd59d6be606..2717a1799d4f 100644 --- a/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr +++ b/posthog/hogql/database/schema/test/__snapshots__/test_session_replay_events.ambr @@ -112,31 +112,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestFilterSessionReplaysByEvents.test_select_by_event[new_events_schema] - ''' - SELECT DISTINCT session_replay_events.session_id AS session_id - FROM session_replay_events - JOIN - (SELECT events.event AS event, - events.`$session_id` AS `$session_id` - FROM events_json AS events PREWHERE greaterOrEquals(events.timestamp, minus(toDateTime64('today', 6, 'UTC'), toIntervalDay(90))) - WHERE equals(events.team_id, 99999)) AS raw_session_replay_events__events ON equals(session_replay_events.session_id, raw_session_replay_events__events.`$session_id`) - WHERE and(equals(session_replay_events.team_id, 99999), equals(raw_session_replay_events__events.event, '$pageview')) - ORDER BY session_replay_events.session_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestFilterSessionReplaysByEvents.test_select_by_event_property ''' SELECT DISTINCT session_replay_events.session_id AS session_id @@ -162,31 +137,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestFilterSessionReplaysByEvents.test_select_by_event_property[new_events_schema] - ''' - SELECT DISTINCT session_replay_events.session_id AS session_id - FROM session_replay_events - JOIN - (SELECT events.properties.`$current_url` AS `properties___$current_url`, - events.`$session_id` AS `$session_id` - FROM events_json AS events PREWHERE greaterOrEquals(events.timestamp, minus(toDateTime64('today', 6, 'UTC'), toIntervalDay(90))) - WHERE equals(events.team_id, 99999)) AS raw_session_replay_events__events ON equals(session_replay_events.session_id, raw_session_replay_events__events.`$session_id`) - WHERE and(equals(session_replay_events.team_id, 99999), ifNull(like(raw_session_replay_events__events.`properties___$current_url`, '%example.com%'), 0)) - ORDER BY session_replay_events.session_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestFilterSessionReplaysByEvents.test_select_by_subquery_on_event_property_without_join ''' SELECT DISTINCT session_replay_events.session_id AS session_id @@ -210,29 +160,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestFilterSessionReplaysByEvents.test_select_by_subquery_on_event_property_without_join[new_events_schema] - ''' - SELECT DISTINCT session_replay_events.session_id AS session_id - FROM session_replay_events - WHERE and(equals(session_replay_events.team_id, 99999), in(session_replay_events.session_id, - (SELECT events.`$session_id` AS `$session_id` - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), and(like(events.properties.`$current_url`, '%example.com%'), isNotNull(events.properties.`$current_url`)))))) - ORDER BY session_replay_events.session_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestFilterSessionReplaysByEvents.test_select_event_property ''' SELECT session_replay_events.session_id AS session_id, @@ -260,33 +187,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestFilterSessionReplaysByEvents.test_select_event_property[new_events_schema] - ''' - SELECT session_replay_events.session_id AS session_id, - any(raw_session_replay_events__events.`properties___$current_url`) AS `any(events.properties.$current_url)` - FROM session_replay_events - JOIN - (SELECT events.properties.`$current_url` AS `properties___$current_url`, - events.`$session_id` AS `$session_id` - FROM events_json AS events PREWHERE greaterOrEquals(events.timestamp, minus(toDateTime64('today', 6, 'UTC'), toIntervalDay(90))) - WHERE equals(events.team_id, 99999)) AS raw_session_replay_events__events ON equals(session_replay_events.session_id, raw_session_replay_events__events.`$session_id`) - WHERE equals(session_replay_events.team_id, 99999) - GROUP BY session_replay_events.session_id - ORDER BY session_replay_events.session_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestFilterSessionReplaysByPerson.test_select_by_event_person ''' SELECT DISTINCT session_replay_events.session_id AS session_id @@ -329,48 +229,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestFilterSessionReplaysByPerson.test_select_by_event_person[new_events_schema] - ''' - SELECT DISTINCT session_replay_events.session_id AS session_id - FROM session_replay_events - JOIN - (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS raw_session_replay_events__events___person_id, - events.`$session_id` AS `$session_id` - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) PREWHERE greaterOrEquals(events.timestamp, minus(toDateTime64('today', 6, 'UTC'), toIntervalDay(90))) - WHERE equals(events.team_id, 99999)) AS raw_session_replay_events__events ON equals(session_replay_events.session_id, raw_session_replay_events__events.`$session_id`) - LEFT JOIN - (SELECT person.id AS id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'person_property'), ''), 'null'), '^"|"$', '') AS properties___person_property - 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 raw_session_replay_events__events__person ON equals(raw_session_replay_events__events.raw_session_replay_events__events___person_id, raw_session_replay_events__events__person.id) - WHERE and(equals(session_replay_events.team_id, 99999), ifNull(equals(ifNull(raw_session_replay_events__events__person.properties___person_property, 'false'), 'true'), 0)) - ORDER BY session_replay_events.session_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestFilterSessionReplaysByPerson.test_select_by_person_distinct_id ''' SELECT DISTINCT session_replay_events.session_id AS session_id diff --git a/posthog/hogql/database/schema/test/__snapshots__/test_sessions_v3.ambr b/posthog/hogql/database/schema/test/__snapshots__/test_sessions_v3.ambr index e1e68bcdf817..8560c75ea4fa 100644 --- a/posthog/hogql/database/schema/test/__snapshots__/test_sessions_v3.ambr +++ b/posthog/hogql/database/schema/test/__snapshots__/test_sessions_v3.ambr @@ -246,31 +246,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestSessionsV3.test_event_sessions_where[new_events_schema] - ''' - SELECT count() AS `count()` - FROM events_json AS events - LEFT JOIN - (SELECT path(argMinMerge(raw_sessions_v3.entry_url)) AS `$entry_pathname`, - raw_sessions_v3.session_id_v7 AS session_id_v7 - FROM raw_sessions_v3 - WHERE equals(raw_sessions_v3.team_id, 99999) - GROUP BY raw_sessions_v3.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - WHERE and(equals(events.team_id, 99999), equals(events__session.`$entry_pathname`, '/pathname')) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestSessionsV3.test_event_sessions_where_event_timestamp ''' SELECT events__session.id AS session_id @@ -296,31 +271,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestSessionsV3.test_event_sessions_where_event_timestamp[new_events_schema] - ''' - SELECT events__session.id AS session_id - FROM events_json AS events - LEFT JOIN - (SELECT toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions_v3.session_id_v7, 64), bitShiftRight(raw_sessions_v3.session_id_v7, 64)))) AS id, - raw_sessions_v3.session_id_v7 AS session_id_v7 - FROM raw_sessions_v3 - WHERE and(equals(raw_sessions_v3.team_id, 99999), equals(raw_sessions_v3.session_timestamp, fromUnixTimestamp64Milli(toUInt64(bitShiftRight(toUInt128(accurateCastOrNull('00000000-0000-0000-0000-000000000000', 'UUID')), 80)))), greaterOrEquals(raw_sessions_v3.session_timestamp, minus('1970-01-01', toIntervalDay(3)))) - GROUP BY raw_sessions_v3.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - WHERE and(equals(events.team_id, 99999), equals(session_id, '00000000-0000-0000-0000-000000000000'), greaterOrEquals(events.timestamp, toDateTime64('1970-01-01', 6, 'UTC'))) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestSessionsV3.test_idempotent_event_counts ''' SELECT sessions.`$pageview_count` AS `$pageview_count`, @@ -436,40 +386,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestSessionsV3.test_persons_and_sessions_on_events[new_events_schema] - ''' - SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, - events__session.`$entry_utm_source` AS `$entry_utm_source` - FROM events_json AS events - LEFT JOIN - (SELECT argMinMerge(raw_sessions_v3.entry_utm_source) AS `$entry_utm_source`, - raw_sessions_v3.session_id_v7 AS session_id_v7 - FROM raw_sessions_v3 - WHERE and(equals(raw_sessions_v3.team_id, 99999), or(equals(raw_sessions_v3.session_timestamp, fromUnixTimestamp64Milli(toUInt64(bitShiftRight(toUInt128(accurateCastOrNull('00000000-0000-0000-0000-000000000000', 'UUID')), 80)))), equals(raw_sessions_v3.session_timestamp, fromUnixTimestamp64Milli(toUInt64(bitShiftRight(toUInt128(accurateCastOrNull('00000000-0000-0000-0000-000000000000', 'UUID')), 80)))))) - GROUP BY raw_sessions_v3.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - WHERE and(equals(events.team_id, 99999), or(equals(events.`$session_id_uuid`, toUInt128(accurateCastOrNull('00000000-0000-0000-0000-000000000000', 'UUID'))), equals(events.`$session_id_uuid`, toUInt128(accurateCastOrNull('00000000-0000-0000-0000-000000000000', 'UUID'))))) - ORDER BY 2 ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestSessionsV3.test_select_session_replay_session_duration ''' SELECT raw_session_replay_events__session.duration AS duration @@ -698,31 +614,3 @@ use_hive_partitioning=0 ''' # --- -# name: TestSessionsV3.test_session_dot_channel_type[new_events_schema] - ''' - SELECT events__session.`$channel_type` AS `$channel_type` - FROM - (SELECT events.`$session_id_uuid` AS `$session_id_uuid` - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.`$session_id_uuid`, toUInt128(accurateCastOrNull('00000000-0000-0000-0000-000000000000', 'UUID')))) - LIMIT 100) AS events - LEFT JOIN - (SELECT multiIf(match(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 3), ''), 'null')), 'cross-network'), 'Cross Network', or(in(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 2), ''), 'null')), tuple('cpc', 'cpm', 'cpv', 'cpa', 'ppc', 'retargeting')), startsWith(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 2), ''), 'null')), 'paid'), tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 5), isNotNull(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 7), ''), 'null'))), coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 1), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 1), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 3), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Paid Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 2), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (coalesce(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 4), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_paid', (cutToFirstSignificantSubdomain(coalesce(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 4), '')), 'source'))), multiIf(ifNull(equals(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 7), ''), 'null'), '1'), 0), 'Paid Search', match(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 3), ''), 'null')), '^(.*video.*)$'), 'Paid Video', tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 6), 'Paid Social', 'Paid Unknown')), and(ifNull(equals(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 4), '$direct'), 0), isNull(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 2), ''), 'null'))), or(isNull(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 1), ''), 'null'))), in(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 1), ''), 'null')), tuple('(direct)', 'direct', '$direct'))), not(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 6))), 'Direct', coalesce(coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 1), ''), 'null')), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 1), ''), 'null')), '')), 'source'))), if(match(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 3), ''), 'null')), '^(.*(([^a-df-z]|^)shop|shopping).*)$'), 'Organic Shopping', NULL), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 2), ''), 'null')), ''), 'medium')), coalesce(dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (coalesce(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 4), ''), 'source')), dictGetOrNull('posthog_test.channel_definition_dict', 'type_if_organic', (cutToFirstSignificantSubdomain(coalesce(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 4), '')), 'source'))), multiIf(match(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 3), ''), 'null')), '^(.*video.*)$'), 'Organic Video', match(lower(nullIf(nullIf(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 2), ''), 'null')), 'push$'), 'Push', tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 6), 'Organic Social', ifNull(equals(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 4), '$direct'), 0), 'Direct', isNotNull(tupleElement(argMinMerge(raw_sessions_v3.entry_channel_type_properties), 4)), 'Referral', 'Unknown'))) AS `$channel_type`, - raw_sessions_v3.session_id_v7 AS session_id_v7 - FROM raw_sessions_v3 - WHERE and(equals(raw_sessions_v3.team_id, 99999), equals(raw_sessions_v3.session_timestamp, fromUnixTimestamp64Milli(toUInt64(bitShiftRight(toUInt128(accurateCastOrNull('00000000-0000-0000-0000-000000000000', 'UUID')), 80))))) - GROUP BY raw_sessions_v3.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- diff --git a/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v2_where_clause_extractor.ambr b/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v2_where_clause_extractor.ambr index fc1f0c3ce26e..c98f498f2962 100644 --- a/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v2_where_clause_extractor.ambr +++ b/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v2_where_clause_extractor.ambr @@ -25,32 +25,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionIdPushdownV2.test_experiment_shape_0_with_pushdown[new_events_schema] - ''' - SELECT - events.`$session_id` AS sid, - events__session.`$entry_pathname` AS entry - FROM - events_json AS events - LEFT JOIN (SELECT - path(nullIf(nullIf(argMinMerge(raw_sessions.entry_url), %(hogql_val_0)s), %(hogql_val_1)s)) AS `$entry_pathname`, - raw_sessions.session_id_v7 AS session_id_v7 - FROM - raw_sessions - WHERE - and(equals(raw_sessions.team_id, ), and(greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(%(hogql_val_2)s, toIntervalDay(3))), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(%(hogql_val_3)s, toIntervalDay(3)))), globalIn(raw_sessions.session_id_v7, (SELECT - DISTINCT events.`$session_id_uuid` AS `$session_id_uuid` - FROM - events_json AS events - WHERE - and(equals(events.team_id, ), equals(events.event, %(hogql_val_4)s), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_5)s, 6, %(hogql_val_6)s)), lessOrEquals(events.timestamp, toDateTime64(%(hogql_val_7)s, 6, %(hogql_val_8)s)))))) - GROUP BY - raw_sessions.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - WHERE - and(equals(events.team_id, ), equals(events.event, %(hogql_val_9)s), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_10)s, 6, %(hogql_val_11)s)), lessOrEquals(events.timestamp, toDateTime64(%(hogql_val_12)s, 6, %(hogql_val_13)s)), ifNull(equals(events__session.`$entry_pathname`, %(hogql_val_14)s), 0)) - LIMIT 50000 - ''' -# --- # name: TestSessionIdPushdownV2.test_experiment_shape_1_without_pushdown ''' SELECT @@ -72,27 +46,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionIdPushdownV2.test_experiment_shape_1_without_pushdown[new_events_schema] - ''' - SELECT - events.`$session_id` AS sid, - events__session.`$entry_pathname` AS entry - FROM - events_json AS events - LEFT JOIN (SELECT - path(nullIf(nullIf(argMinMerge(raw_sessions.entry_url), %(hogql_val_0)s), %(hogql_val_1)s)) AS `$entry_pathname`, - raw_sessions.session_id_v7 AS session_id_v7 - FROM - raw_sessions - WHERE - and(equals(raw_sessions.team_id, ), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(%(hogql_val_2)s, toIntervalDay(3))), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(%(hogql_val_3)s, toIntervalDay(3)))) - GROUP BY - raw_sessions.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - WHERE - and(equals(events.team_id, ), equals(events.event, %(hogql_val_4)s), greaterOrEquals(events.timestamp, toDateTime64(%(hogql_val_5)s, 6, %(hogql_val_6)s)), lessOrEquals(events.timestamp, toDateTime64(%(hogql_val_7)s, 6, %(hogql_val_8)s)), ifNull(equals(events__session.`$entry_pathname`, %(hogql_val_9)s), 0)) - LIMIT 50000 - ''' -# --- # name: TestSessionsV2QueriesHogQLToClickhouse.test_join_with_events ''' SELECT @@ -116,29 +69,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsV2QueriesHogQLToClickhouse.test_join_with_events[new_events_schema] - ''' - SELECT - sessions.session_id AS session_id, - uniq(events.uuid) AS uniq_uuid - FROM - events_json AS events - JOIN (SELECT - toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions.session_id_v7, 64), bitShiftRight(raw_sessions.session_id_v7, 64)))) AS session_id, - raw_sessions.session_id_v7 AS session_id_v7 - FROM - raw_sessions - WHERE - and(equals(raw_sessions.team_id, ), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(%(hogql_val_0)s, toIntervalDay(3)))) - GROUP BY - raw_sessions.session_id_v7) AS sessions ON equals(events.`$session_id`, sessions.session_id) - WHERE - and(equals(events.team_id, ), greater(events.timestamp, toDateTime64(%(hogql_val_1)s, 6, %(hogql_val_2)s))) - GROUP BY - sessions.session_id - LIMIT 50000 - ''' -# --- # name: TestSessionsV2QueriesHogQLToClickhouse.test_select_query_alias_type_does_not_crash ''' SELECT @@ -227,48 +157,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsV2QueriesHogQLToClickhouse.test_session_breakdown[new_events_schema] - ''' - SELECT - count(DISTINCT e.`$session_id`) AS total, - toStartOfDay(toTimeZone(e.timestamp, %(hogql_val_7)s)) AS day_start, - multiIf(and(greaterOrEquals(e__session.`$session_duration`, 2.0), less(e__session.`$session_duration`, 4.5)), %(hogql_val_8)s, and(greaterOrEquals(e__session.`$session_duration`, 4.5), less(e__session.`$session_duration`, 27.0)), %(hogql_val_9)s, and(greaterOrEquals(e__session.`$session_duration`, 27.0), less(e__session.`$session_duration`, 44.0)), %(hogql_val_10)s, and(greaterOrEquals(e__session.`$session_duration`, 44.0), less(e__session.`$session_duration`, 48.0)), %(hogql_val_11)s, and(greaterOrEquals(e__session.`$session_duration`, 48.0), less(e__session.`$session_duration`, 57.5)), %(hogql_val_12)s, and(greaterOrEquals(e__session.`$session_duration`, 57.5), less(e__session.`$session_duration`, 61.0)), %(hogql_val_13)s, and(greaterOrEquals(e__session.`$session_duration`, 61.0), less(e__session.`$session_duration`, 74.0)), %(hogql_val_14)s, and(greaterOrEquals(e__session.`$session_duration`, 74.0), less(e__session.`$session_duration`, 90.0)), %(hogql_val_15)s, and(greaterOrEquals(e__session.`$session_duration`, 90.0), less(e__session.`$session_duration`, 98.5)), %(hogql_val_16)s, and(greaterOrEquals(e__session.`$session_duration`, 98.5), less(e__session.`$session_duration`, 167.01)), %(hogql_val_17)s, %(hogql_val_18)s) 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, ) - GROUP BY - person_distinct_id_overrides.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 - dateDiff(%(hogql_val_0)s, min(toTimeZone(raw_sessions.min_timestamp, %(hogql_val_1)s)), max(toTimeZone(raw_sessions.max_timestamp, %(hogql_val_2)s))) AS `$session_duration`, - raw_sessions.session_id_v7 AS session_id_v7 - FROM - raw_sessions - WHERE - and(equals(raw_sessions.team_id, ), greaterOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), minus(toStartOfDay(assumeNotNull(toDateTime(%(hogql_val_3)s, %(hogql_val_4)s))), toIntervalDay(3))), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(assumeNotNull(toDateTime(%(hogql_val_5)s, %(hogql_val_6)s)), toIntervalDay(3)))) - GROUP BY - raw_sessions.session_id_v7) AS e__session ON equals(e.`$session_id_uuid`, e__session.session_id_v7) - WHERE - and(equals(e.team_id, ), and(greaterOrEquals(toTimeZone(e.timestamp, %(hogql_val_19)s), toStartOfDay(assumeNotNull(toDateTime(%(hogql_val_20)s, %(hogql_val_21)s)))), lessOrEquals(toTimeZone(e.timestamp, %(hogql_val_22)s), assumeNotNull(toDateTime(%(hogql_val_23)s, %(hogql_val_24)s))), equals(e.event, %(hogql_val_25)s), in(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), (SELECT - cohortpeople.person_id AS person_id - FROM - cohortpeople - WHERE - and(equals(cohortpeople.team_id, ), and(equals(cohortpeople.cohort_id, 2), equals(cohortpeople.version, 0))))))) - GROUP BY - day_start, - breakdown_value - LIMIT 50000 - ''' -# --- # name: TestSessionsV2QueriesHogQLToClickhouse.test_session_replay_query ''' SELECT @@ -320,34 +208,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsV2QueriesHogQLToClickhouse.test_union[new_events_schema] - ''' - SELECT - 0 AS duration - LIMIT 50000 - UNION ALL - SELECT - events__session.`$session_duration` AS duration - FROM - (SELECT - events.`$session_id_uuid` AS `$session_id_uuid` - FROM - events_json AS events - WHERE - and(equals(events.team_id, ), less(events.timestamp, today())) - LIMIT 50000) AS events - LEFT JOIN (SELECT - dateDiff(%(hogql_val_0)s, min(toTimeZone(raw_sessions.min_timestamp, %(hogql_val_1)s)), max(toTimeZone(raw_sessions.max_timestamp, %(hogql_val_2)s))) AS `$session_duration`, - raw_sessions.session_id_v7 AS session_id_v7 - FROM - raw_sessions - WHERE - and(equals(raw_sessions.team_id, ), lessOrEquals(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(raw_sessions.session_id_v7, 80)), 1000)), plus(today(), toIntervalDay(3)))) - GROUP BY - raw_sessions.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - LIMIT 50000 - ''' -# --- # name: TestSessionsV2QueriesHogQLToClickhouse.test_urls_in_sessions_in_timestamp_query ''' SELECT diff --git a/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v3_where_clause_extractor.ambr b/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v3_where_clause_extractor.ambr index 4ffe055a20fc..817e5586e371 100644 --- a/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v3_where_clause_extractor.ambr +++ b/posthog/hogql/database/schema/util/test/__snapshots__/test_session_v3_where_clause_extractor.ambr @@ -22,29 +22,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsV3QueriesHogQLToClickhouse.test_join_with_events[new_events_schema] - ''' - SELECT - sessions.session_id AS session_id, - uniq(events.uuid) AS uniq_uuid - FROM - events_json AS events - JOIN (SELECT - toString(reinterpretAsUUID(bitOr(bitShiftLeft(raw_sessions_v3.session_id_v7, 64), bitShiftRight(raw_sessions_v3.session_id_v7, 64)))) AS session_id, - raw_sessions_v3.session_id_v7 AS session_id_v7 - FROM - raw_sessions_v3 - WHERE - and(equals(raw_sessions_v3.team_id, ), greaterOrEquals(raw_sessions_v3.session_timestamp, minus(%(hogql_val_0)s, toIntervalDay(3)))) - GROUP BY - raw_sessions_v3.session_id_v7) AS sessions ON equals(events.`$session_id`, sessions.session_id) - WHERE - and(equals(events.team_id, ), greater(events.timestamp, toDateTime64(%(hogql_val_1)s, 6, %(hogql_val_2)s))) - GROUP BY - sessions.session_id - LIMIT 50000 - ''' -# --- # name: TestSessionsV3QueriesHogQLToClickhouse.test_point_query ''' SELECT @@ -152,48 +129,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsV3QueriesHogQLToClickhouse.test_session_breakdown[new_events_schema] - ''' - SELECT - count(DISTINCT e.`$session_id`) AS total, - toStartOfDay(toTimeZone(e.timestamp, %(hogql_val_7)s)) AS day_start, - multiIf(and(greaterOrEquals(e__session.`$session_duration`, 2.0), less(e__session.`$session_duration`, 4.5)), %(hogql_val_8)s, and(greaterOrEquals(e__session.`$session_duration`, 4.5), less(e__session.`$session_duration`, 27.0)), %(hogql_val_9)s, and(greaterOrEquals(e__session.`$session_duration`, 27.0), less(e__session.`$session_duration`, 44.0)), %(hogql_val_10)s, and(greaterOrEquals(e__session.`$session_duration`, 44.0), less(e__session.`$session_duration`, 48.0)), %(hogql_val_11)s, and(greaterOrEquals(e__session.`$session_duration`, 48.0), less(e__session.`$session_duration`, 57.5)), %(hogql_val_12)s, and(greaterOrEquals(e__session.`$session_duration`, 57.5), less(e__session.`$session_duration`, 61.0)), %(hogql_val_13)s, and(greaterOrEquals(e__session.`$session_duration`, 61.0), less(e__session.`$session_duration`, 74.0)), %(hogql_val_14)s, and(greaterOrEquals(e__session.`$session_duration`, 74.0), less(e__session.`$session_duration`, 90.0)), %(hogql_val_15)s, and(greaterOrEquals(e__session.`$session_duration`, 90.0), less(e__session.`$session_duration`, 98.5)), %(hogql_val_16)s, and(greaterOrEquals(e__session.`$session_duration`, 98.5), less(e__session.`$session_duration`, 167.01)), %(hogql_val_17)s, %(hogql_val_18)s) 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, ) - GROUP BY - person_distinct_id_overrides.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 - dateDiff(%(hogql_val_0)s, min(toTimeZone(raw_sessions_v3.min_timestamp, %(hogql_val_1)s)), max(toTimeZone(raw_sessions_v3.max_timestamp, %(hogql_val_2)s))) AS `$session_duration`, - raw_sessions_v3.session_id_v7 AS session_id_v7 - FROM - raw_sessions_v3 - WHERE - and(equals(raw_sessions_v3.team_id, ), greaterOrEquals(raw_sessions_v3.session_timestamp, minus(toStartOfDay(assumeNotNull(toDateTime(%(hogql_val_3)s, %(hogql_val_4)s))), toIntervalDay(3))), lessOrEquals(raw_sessions_v3.session_timestamp, plus(assumeNotNull(toDateTime(%(hogql_val_5)s, %(hogql_val_6)s)), toIntervalDay(3)))) - GROUP BY - raw_sessions_v3.session_id_v7) AS e__session ON equals(e.`$session_id_uuid`, e__session.session_id_v7) - WHERE - and(equals(e.team_id, ), and(greaterOrEquals(toTimeZone(e.timestamp, %(hogql_val_19)s), toStartOfDay(assumeNotNull(toDateTime(%(hogql_val_20)s, %(hogql_val_21)s)))), lessOrEquals(toTimeZone(e.timestamp, %(hogql_val_22)s), assumeNotNull(toDateTime(%(hogql_val_23)s, %(hogql_val_24)s))), equals(e.event, %(hogql_val_25)s), in(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), (SELECT - cohortpeople.person_id AS person_id - FROM - cohortpeople - WHERE - and(equals(cohortpeople.team_id, ), and(equals(cohortpeople.cohort_id, 2), equals(cohortpeople.version, 0))))))) - GROUP BY - day_start, - breakdown_value - LIMIT 50000 - ''' -# --- # name: TestSessionsV3QueriesHogQLToClickhouse.test_session_replay_query ''' SELECT @@ -288,34 +223,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsV3QueriesHogQLToClickhouse.test_union[new_events_schema] - ''' - SELECT - 0 AS duration - LIMIT 50000 - UNION ALL - SELECT - events__session.`$session_duration` AS duration - FROM - (SELECT - events.`$session_id_uuid` AS `$session_id_uuid` - FROM - events_json AS events - WHERE - and(equals(events.team_id, ), less(events.timestamp, today())) - LIMIT 50000) AS events - LEFT JOIN (SELECT - dateDiff(%(hogql_val_0)s, min(toTimeZone(raw_sessions_v3.min_timestamp, %(hogql_val_1)s)), max(toTimeZone(raw_sessions_v3.max_timestamp, %(hogql_val_2)s))) AS `$session_duration`, - raw_sessions_v3.session_id_v7 AS session_id_v7 - FROM - raw_sessions_v3 - WHERE - and(equals(raw_sessions_v3.team_id, ), lessOrEquals(raw_sessions_v3.session_timestamp, plus(today(), toIntervalDay(3)))) - GROUP BY - raw_sessions_v3.session_id_v7) AS events__session ON equals(events.`$session_id_uuid`, events__session.session_id_v7) - LIMIT 50000 - ''' -# --- # name: TestSessionsV3QueriesHogQLToClickhouse.test_urls_in_sessions_in_timestamp_query ''' SELECT diff --git a/posthog/hogql/database/schema/util/test/__snapshots__/test_session_where_clause_extractor.ambr b/posthog/hogql/database/schema/util/test/__snapshots__/test_session_where_clause_extractor.ambr index a97144d58fc5..dd1c0d2fbeb7 100644 --- a/posthog/hogql/database/schema/util/test/__snapshots__/test_session_where_clause_extractor.ambr +++ b/posthog/hogql/database/schema/util/test/__snapshots__/test_session_where_clause_extractor.ambr @@ -22,29 +22,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsQueriesHogQLToClickhouse.test_join_with_events[new_events_schema] - ''' - SELECT - sessions.session_id AS session_id, - uniq(events.uuid) AS uniq_uuid - FROM - events_json AS events - JOIN (SELECT - sessions.session_id AS session_id - FROM - sessions - WHERE - and(equals(sessions.team_id, ), greaterOrEquals(sessions.min_timestamp, minus(%(hogql_val_0)s, toIntervalDay(3)))) - GROUP BY - sessions.session_id, - sessions.session_id) AS sessions ON equals(events.`$session_id`, sessions.session_id) - WHERE - and(equals(events.team_id, ), greater(events.timestamp, toDateTime64(%(hogql_val_1)s, 6, %(hogql_val_2)s))) - GROUP BY - sessions.session_id - LIMIT 50000 - ''' -# --- # name: TestSessionsQueriesHogQLToClickhouse.test_select_with_timestamp ''' SELECT @@ -108,49 +85,6 @@ LIMIT 50000 ''' # --- -# name: TestSessionsQueriesHogQLToClickhouse.test_session_breakdown[new_events_schema] - ''' - SELECT - count(DISTINCT e.`$session_id`) AS total, - toStartOfDay(toTimeZone(e.timestamp, %(hogql_val_7)s)) AS day_start, - multiIf(and(greaterOrEquals(e__session.`$session_duration`, 2.0), less(e__session.`$session_duration`, 4.5)), %(hogql_val_8)s, and(greaterOrEquals(e__session.`$session_duration`, 4.5), less(e__session.`$session_duration`, 27.0)), %(hogql_val_9)s, and(greaterOrEquals(e__session.`$session_duration`, 27.0), less(e__session.`$session_duration`, 44.0)), %(hogql_val_10)s, and(greaterOrEquals(e__session.`$session_duration`, 44.0), less(e__session.`$session_duration`, 48.0)), %(hogql_val_11)s, and(greaterOrEquals(e__session.`$session_duration`, 48.0), less(e__session.`$session_duration`, 57.5)), %(hogql_val_12)s, and(greaterOrEquals(e__session.`$session_duration`, 57.5), less(e__session.`$session_duration`, 61.0)), %(hogql_val_13)s, and(greaterOrEquals(e__session.`$session_duration`, 61.0), less(e__session.`$session_duration`, 74.0)), %(hogql_val_14)s, and(greaterOrEquals(e__session.`$session_duration`, 74.0), less(e__session.`$session_duration`, 90.0)), %(hogql_val_15)s, and(greaterOrEquals(e__session.`$session_duration`, 90.0), less(e__session.`$session_duration`, 98.5)), %(hogql_val_16)s, and(greaterOrEquals(e__session.`$session_duration`, 98.5), less(e__session.`$session_duration`, 167.01)), %(hogql_val_17)s, %(hogql_val_18)s) 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, ) - GROUP BY - person_distinct_id_overrides.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 - dateDiff(%(hogql_val_0)s, min(toTimeZone(sessions.min_timestamp, %(hogql_val_1)s)), max(toTimeZone(sessions.max_timestamp, %(hogql_val_2)s))) AS `$session_duration`, - sessions.session_id AS session_id - FROM - sessions - WHERE - and(equals(sessions.team_id, ), greaterOrEquals(sessions.min_timestamp, minus(toStartOfDay(assumeNotNull(toDateTime(%(hogql_val_3)s, %(hogql_val_4)s))), toIntervalDay(3))), lessOrEquals(sessions.min_timestamp, plus(assumeNotNull(toDateTime(%(hogql_val_5)s, %(hogql_val_6)s)), toIntervalDay(3)))) - GROUP BY - sessions.session_id, - sessions.session_id) AS e__session ON equals(e.`$session_id`, e__session.session_id) - WHERE - and(equals(e.team_id, ), and(greaterOrEquals(toTimeZone(e.timestamp, %(hogql_val_19)s), toStartOfDay(assumeNotNull(toDateTime(%(hogql_val_20)s, %(hogql_val_21)s)))), lessOrEquals(toTimeZone(e.timestamp, %(hogql_val_22)s), assumeNotNull(toDateTime(%(hogql_val_23)s, %(hogql_val_24)s))), equals(e.event, %(hogql_val_25)s), in(if(not(empty(e__override.distinct_id)), e__override.person_id, e.person_id), (SELECT - cohortpeople.person_id AS person_id - FROM - cohortpeople - WHERE - and(equals(cohortpeople.team_id, ), and(equals(cohortpeople.cohort_id, 2), equals(cohortpeople.version, 0))))))) - GROUP BY - day_start, - breakdown_value - LIMIT 50000 - ''' -# --- # name: TestSessionsQueriesHogQLToClickhouse.test_session_replay_query ''' SELECT @@ -204,32 +138,3 @@ LIMIT 50000 ''' # --- -# name: TestSessionsQueriesHogQLToClickhouse.test_union[new_events_schema] - ''' - SELECT - 0 AS duration - LIMIT 50000 - UNION ALL - SELECT - events__session.`$session_duration` AS duration - FROM - (SELECT - events.`$session_id` AS `$session_id` - FROM - events_json AS events - WHERE - and(equals(events.team_id, ), less(events.timestamp, today())) - LIMIT 50000) AS events - LEFT JOIN (SELECT - dateDiff(%(hogql_val_0)s, min(toTimeZone(sessions.min_timestamp, %(hogql_val_1)s)), max(toTimeZone(sessions.max_timestamp, %(hogql_val_2)s))) AS `$session_duration`, - sessions.session_id AS session_id - FROM - sessions - WHERE - and(equals(sessions.team_id, ), lessOrEquals(sessions.min_timestamp, plus(today(), toIntervalDay(3)))) - GROUP BY - sessions.session_id, - sessions.session_id) AS events__session ON equals(events.`$session_id`, events__session.session_id) - LIMIT 50000 - ''' -# --- diff --git a/posthog/hogql/database/test/__snapshots__/test_database.ambr b/posthog/hogql/database/test/__snapshots__/test_database.ambr index c7cf79fc2622..c8df2ba36a67 100644 --- a/posthog/hogql/database/test/__snapshots__/test_database.ambr +++ b/posthog/hogql/database/test/__snapshots__/test_database.ambr @@ -14,21 +14,6 @@ LIMIT 50000 ''' # --- -# name: TestDatabase.test_database_warehouse_joins_persons_poe_v2[new_events_schema] - ''' - - SELECT events__some_field.key AS key - FROM events_json AS events LEFT JOIN ( - SELECT groups.key AS key, key AS events__some_field___key - FROM ( - SELECT groups.group_type_index AS index, groups.group_key AS key - FROM groups - WHERE equals(groups.team_id, 420) - GROUP BY groups.group_type_index, groups.group_key) AS groups) AS events__some_field ON equals(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))), events__some_field.events__some_field___key) - WHERE equals(events.team_id, 420) - LIMIT 50000 - ''' -# --- # name: TestDatabase.test_database_warehouse_joins_persons_poe_v2_source_key_ast_call ''' @@ -44,21 +29,6 @@ LIMIT 50000 ''' # --- -# name: TestDatabase.test_database_warehouse_joins_persons_poe_v2_source_key_ast_call[new_events_schema] - ''' - - SELECT events__some_field.key AS key - FROM events_json AS events LEFT JOIN ( - SELECT groups.key AS key, key AS events__some_field___key - FROM ( - SELECT groups.group_type_index AS index, groups.group_key AS key - FROM groups - WHERE equals(groups.team_id, 420) - GROUP BY groups.group_type_index, groups.group_key) AS groups) AS events__some_field ON equals(toString(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email)))))), events__some_field.events__some_field___key) - WHERE equals(events.team_id, 420) - LIMIT 50000 - ''' -# --- # name: TestDatabase.test_database_with_warehouse_tables_and_saved_queries_n_plus_1 ''' SELECT "posthog_datawarehousesavedquery"."created_by_id", diff --git a/posthog/hogql/functions/test/__snapshots__/test_action.ambr b/posthog/hogql/functions/test/__snapshots__/test_action.ambr index 44d184082361..b5625c5fc024 100644 --- a/posthog/hogql/functions/test/__snapshots__/test_action.ambr +++ b/posthog/hogql/functions/test/__snapshots__/test_action.ambr @@ -21,25 +21,3 @@ LIMIT 100 ''' # --- -# name: TestAction.test_matches_action_with_alias[new_events_schema] - ''' - -- ClickHouse - SELECT - e.event AS event - FROM - events_json AS e - WHERE - and(equals(e.team_id, 99999), equals(e.event, %(hogql_val_0)s), and(equals(e.properties.`$current_url`, %(hogql_val_1)s), isNotNull(e.properties.`$current_url`))) - LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, transform_null_in=1, optimize_min_equality_disjunction_chain_length=4294967295, optimize_rewrite_aggregate_function_with_if=0, optimize_min_inequality_conjunction_chain_length=4294967295, allow_experimental_join_condition=1, use_hive_partitioning=0 - - -- HogQL - SELECT - event - FROM - events AS e - WHERE - and(equals(event, 'RANDOM_TEST_ID::UUID'), equals(e.properties.$current_url, 'https://posthog.com/feedback/123?vip=1')) - LIMIT 100 - ''' -# --- diff --git a/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr b/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr index 75212464ea78..a32cc32f11c5 100644 --- a/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr +++ b/posthog/hogql/functions/test/__snapshots__/test_cohort.ambr @@ -25,32 +25,6 @@ LIMIT 100 ''' # --- -# name: TestCohort.test_in_cohort_dynamic[new_events_schema] - ''' - -- ClickHouse - SELECT events.event AS event - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), in(events.person_id, ( - SELECT cohortpeople.person_id AS person_id - FROM cohortpeople - WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, XX)) - GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version - HAVING greater(sum(cohortpeople.sign), 0))), equals(events.event, %(hogql_val_0)s)) - LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, transform_null_in=1, optimize_min_equality_disjunction_chain_length=4294967295, optimize_rewrite_aggregate_function_with_if=0, optimize_min_inequality_conjunction_chain_length=4294967295, allow_experimental_join_condition=1, use_hive_partitioning=0 - - -- HogQL - SELECT event - FROM events - WHERE and(in(person_id, ( - SELECT person_id - FROM raw_cohort_people - WHERE equals(cohort_id, XX) - GROUP BY person_id, cohort_id, version - HAVING greater(sum(sign), 0))), equals(event, 'RANDOM_TEST_ID::UUID')) - LIMIT 100 - ''' -# --- # name: TestCohort.test_in_cohort_dynamic_other_team_in_project ''' -- ClickHouse @@ -77,32 +51,6 @@ LIMIT 100 ''' # --- -# name: TestCohort.test_in_cohort_dynamic_other_team_in_project[new_events_schema] - ''' - -- ClickHouse - SELECT events.event AS event - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), in(events.person_id, ( - SELECT cohortpeople.person_id AS person_id - FROM cohortpeople - WHERE and(equals(cohortpeople.team_id, 99999), equals(cohortpeople.cohort_id, XX)) - GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version - HAVING greater(sum(cohortpeople.sign), 0))), equals(events.event, %(hogql_val_0)s)) - LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, transform_null_in=1, optimize_min_equality_disjunction_chain_length=4294967295, optimize_rewrite_aggregate_function_with_if=0, optimize_min_inequality_conjunction_chain_length=4294967295, allow_experimental_join_condition=1, use_hive_partitioning=0 - - -- HogQL - SELECT event - FROM events - WHERE and(in(person_id, ( - SELECT person_id - FROM raw_cohort_people - WHERE equals(cohort_id, XX) - GROUP BY person_id, cohort_id, version - HAVING greater(sum(sign), 0))), equals(event, 'RANDOM_TEST_ID::UUID')) - LIMIT 100 - ''' -# --- # name: TestCohort.test_in_cohort_static ''' -- ClickHouse @@ -125,51 +73,6 @@ LIMIT 100 ''' # --- -# name: TestCohort.test_in_cohort_static[new_events_schema] - ''' - -- ClickHouse - SELECT events.event AS event - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), in(events.person_id, ( - SELECT person_static_cohort.person_id AS person_id - FROM person_static_cohort - WHERE and(equals(person_static_cohort.team_id, 99999), equals(person_static_cohort.cohort_id, XX))))) - LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, transform_null_in=1, optimize_min_equality_disjunction_chain_length=4294967295, optimize_rewrite_aggregate_function_with_if=0, optimize_min_inequality_conjunction_chain_length=4294967295, allow_experimental_join_condition=1, use_hive_partitioning=0 - - -- HogQL - SELECT event - FROM events - WHERE in(person_id, ( - SELECT person_id - FROM static_cohort_people - WHERE equals(cohort_id, XX))) - LIMIT 100 - ''' -# --- -# name: TestCohort.test_in_cohort_strings[new_events_schema] - ''' - -- ClickHouse - SELECT events.event AS event - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), in(events.person_id, ( - SELECT person_static_cohort.person_id AS person_id - FROM person_static_cohort - WHERE and(equals(person_static_cohort.team_id, 99999), equals(person_static_cohort.cohort_id, XX))))) - LIMIT 100 - SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0, transform_null_in=1, optimize_min_equality_disjunction_chain_length=4294967295, optimize_rewrite_aggregate_function_with_if=0, optimize_min_inequality_conjunction_chain_length=4294967295, allow_experimental_join_condition=1, use_hive_partitioning=0 - - -- HogQL - SELECT event - FROM events - WHERE in(person_id, ( - SELECT person_id - FROM static_cohort_people - WHERE equals(cohort_id, XX))) - LIMIT 100 - ''' -# --- -# --- # name: TestCohort.test_in_cohort_strings ''' -- ClickHouse diff --git a/posthog/hogql/printer/test/__snapshots__/test_printer.ambr b/posthog/hogql/printer/test/__snapshots__/test_printer.ambr index bb1aabaa472f..0605c48b1f74 100644 --- a/posthog/hogql/printer/test/__snapshots__/test_printer.ambr +++ b/posthog/hogql/printer/test/__snapshots__/test_printer.ambr @@ -19,26 +19,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_force_data_skipping_indices_fails_when_index_cannot_be_used[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(concat(ifNull(toString(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))))), ''), ''), 'foo')) - LIMIT 100 SETTINGS force_data_skipping_indices='bloom_filter_mat_test_prop', - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestMaterializedColumnOptimization.test_force_data_skipping_indices_works_with_simple_equality ''' SELECT events.distinct_id AS distinct_id @@ -59,26 +39,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_force_data_skipping_indices_works_with_simple_equality[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), ifNull(equals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'foo'), 0)) - LIMIT 100 SETTINGS force_data_skipping_indices='bloom_filter_mat_test_prop', - readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col ''' SELECT events.distinct_id AS distinct_id @@ -319,11 +279,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.10] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, '%@posthog.com'), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -339,11 +299,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.11] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%@posthog.com'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -359,11 +319,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.1] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.10 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -379,11 +339,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.2] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.11 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -399,11 +359,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.3] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.2 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, 'hello@posthog.com'), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -419,11 +379,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.4] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.3 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, 'hello@posthog.com'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -439,11 +399,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.5] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.4 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, '%null%'), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -459,11 +419,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.6] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.5 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%null%'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -479,11 +439,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.7] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.6 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, '%'), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -499,11 +459,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.8] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.7 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -519,11 +479,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema.9] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.8 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, ''), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -539,11 +499,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_0_no_mat_col[new_events_schema] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.9 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, ''), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -559,11 +519,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, '%@posthog.com'), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ilike(events.mat_test_prop, '%@posthog.com')) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -579,11 +539,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.1 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.1 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%@posthog.com'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), notILike(events.mat_test_prop, '%@posthog.com')) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -599,11 +559,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.10 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.10 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(events.mat_test_prop)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(nullIf(nullIf(events.mat_test_prop, ''), 'null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -619,11 +579,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.11 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.11 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(events.mat_test_prop)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(nullIf(nullIf(events.mat_test_prop, ''), 'null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -639,11 +599,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.2 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.2 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, 'hello@posthog.com'), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ilike(events.mat_test_prop, 'hello@posthog.com')) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -659,11 +619,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.3 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.3 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, 'hello@posthog.com'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), notILike(events.mat_test_prop, 'hello@posthog.com')) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -679,11 +639,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.4 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.4 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, '%null%'), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%null%'), 0)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -699,11 +659,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.5 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.5 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%null%'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%null%'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -719,11 +679,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.6 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.6 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, '%'), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%'), 0)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -739,11 +699,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.7 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.7 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -759,11 +719,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.8 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.8 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(ilike(events.mat_test_prop, ''), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), ''), 0)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -779,11 +739,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col.9 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.9 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, ''), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), ''), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -799,11 +759,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.10] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('%@posthog.com')), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -819,11 +779,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.11] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%@posthog.com'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -839,11 +799,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.1] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.10 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -859,11 +819,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.2] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.11 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -879,11 +839,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.3] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.2 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('hello@posthog.com')), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -899,11 +859,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.4] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.3 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, 'hello@posthog.com'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -919,11 +879,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.5] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.4 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('%null%')), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -939,11 +899,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.6] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.5 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%null%'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -959,11 +919,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.7] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.6 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('%')), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -979,11 +939,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.8] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.7 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -999,11 +959,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.9] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.8 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('')), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1019,11 +979,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema] +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.9 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, ''), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1039,11 +999,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ilike(events.mat_test_prop, '%@posthog.com')) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), like(lower(events.mat_test_prop), lower('%@posthog.com'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1059,7 +1019,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.1 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.1 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1079,7 +1039,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.10 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.10 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1099,7 +1059,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.11 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.11 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1119,11 +1079,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.2 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.2 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ilike(events.mat_test_prop, 'hello@posthog.com')) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), like(lower(events.mat_test_prop), lower('hello@posthog.com'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1139,7 +1099,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.3 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.3 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1159,7 +1119,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.4 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.4 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1179,7 +1139,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.5 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.5 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1199,7 +1159,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.6 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.6 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1219,7 +1179,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.7 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.7 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1239,7 +1199,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.8 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.8 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1259,7 +1219,7 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col.9 +# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.9 ''' SELECT events.distinct_id AS distinct_id FROM events @@ -1279,11 +1239,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.10] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1299,11 +1259,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.11] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1319,11 +1279,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.1] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.10 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple(''))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1339,11 +1299,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.2] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.11 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1359,11 +1319,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.3] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.12 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1379,11 +1339,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.4] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.13 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1399,11 +1359,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.5] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.14 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', ''))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1419,11 +1379,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.6] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.15 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', '')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1439,11 +1399,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.7] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.2 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'other_value'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1459,11 +1419,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.8] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.3 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'other_value')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1479,11 +1439,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.9] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.4 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1499,11 +1459,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.5 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1519,11 +1479,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.6 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('%@posthog.com')), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('NULL'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1539,11 +1499,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.1 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.7 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%@posthog.com'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1559,11 +1519,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.10 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.8 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(events.mat_test_prop)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null', 'NULL'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1579,11 +1539,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.11 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.9 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(events.mat_test_prop)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null', 'NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1599,11 +1559,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.2 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('hello@posthog.com')), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1619,11 +1579,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.3 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.1 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, 'hello@posthog.com'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1639,11 +1599,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.4 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.10 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('%null%')), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has([''], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1659,11 +1619,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.5 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.11 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%null%'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1679,11 +1639,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.6 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.12 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('%')), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1699,11 +1659,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.7 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.13 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, '%'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1719,11 +1679,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.8 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.14 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), and(like(lower(coalesce(events.mat_test_prop, '')), lower('')), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', ''], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1739,11 +1699,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower.9 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.15 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(events.mat_test_prop, ''), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', '')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1759,11 +1719,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.10] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.2 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'other_value'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1779,11 +1739,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.11] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.3 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1799,11 +1759,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.1] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.4 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1819,11 +1779,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.2] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.5 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1839,11 +1799,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.3] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.6 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1859,11 +1819,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.4] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.7 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1879,11 +1839,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.5] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.8 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null', 'NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1899,11 +1859,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.6] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.9 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null', 'NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1919,11 +1879,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.7] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com'], events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1939,11 +1899,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.8] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1959,11 +1919,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema.9] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.10 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple(''))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1979,11 +1939,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_3_nullable_mat_col_with_ngram_lower[new_events_schema] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.11 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -1999,11 +1959,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.12 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), like(lower(events.mat_test_prop), lower('%@posthog.com'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2019,11 +1979,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.1 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.13 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), notILike(events.mat_test_prop, '%@posthog.com')) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2039,11 +1999,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.10 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.14 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(nullIf(nullIf(events.mat_test_prop, ''), 'null'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', ''))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2059,11 +2019,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.11 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.15 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(nullIf(nullIf(events.mat_test_prop, ''), 'null'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', '')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2079,11 +2039,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.2 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.2 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), like(lower(events.mat_test_prop), lower('hello@posthog.com'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com', 'other_value'], events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2099,11 +2059,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.3 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.3 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), notILike(events.mat_test_prop, 'hello@posthog.com')) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2119,11 +2079,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.4 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.4 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%null%'), 0)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2139,11 +2099,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.5 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.5 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%null%'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2159,11 +2119,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.6 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.6 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%'), 0)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['NULL'], events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2179,11 +2139,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.7 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.7 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), '%'), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('NULL'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2199,11 +2159,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.8 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.8 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), ''), 0)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2219,11 +2179,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower.9 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.9 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(nullIf(nullIf(events.mat_test_prop, ''), 'null'), ''), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2239,11 +2199,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.10] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2259,11 +2219,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.11] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), isNotNull(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2279,11 +2239,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.1] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.10 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has([''], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2299,11 +2259,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.2] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.11 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2319,11 +2279,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.3] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.12 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'hello@posthog.com'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2339,11 +2299,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.4] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.13 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2359,11 +2319,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.5] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.14 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%null%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', ''], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2379,11 +2339,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.6] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.15 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', '')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2399,11 +2359,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.7] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.2 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%'), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'other_value'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2419,11 +2379,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.8] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.3 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2439,11 +2399,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema.9] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.4 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(notILike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), ''), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2459,11 +2419,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_ilike_and_not_ilike_optimization_gives_correct_results_4_non_nullable_mat_col_with_ngram_lower[new_events_schema] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.5 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_ilike_test'), ifNull(ilike(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), '%@posthog.com'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2479,11 +2439,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.6 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2499,11 +2459,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.1 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.7 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2519,11 +2479,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.10 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.8 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple(''))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null', 'NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2539,11 +2499,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.11 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.9 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null', 'NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2559,11 +2519,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.12 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'null'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com'], events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2579,11 +2539,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.13 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.1 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'null')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2599,11 +2559,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.14 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.10 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', ''))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple(''))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2619,11 +2579,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.15 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.11 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', '')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2639,11 +2599,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.2 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.12 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'other_value'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2659,11 +2619,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.3 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.13 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('hello@posthog.com', 'other_value')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2679,11 +2639,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.4 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.14 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', ''))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2699,11 +2659,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.5 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.15 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', '')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2719,11 +2679,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.6 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.2 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('NULL'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com', 'other_value'], events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2739,11 +2699,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.7 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.3 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('NULL')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2759,11 +2719,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.8 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.4 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null', 'NULL'))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2779,11 +2739,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col.9 +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.5 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null', 'NULL')), 1)) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2799,11 +2759,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.10] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.6 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple(''))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['NULL'], events.mat_test_prop)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2819,11 +2779,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.11] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.7 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('')), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('NULL'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2839,11 +2799,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.12] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.8 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null'))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2859,11 +2819,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.13] +# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.9 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null')), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2879,11 +2839,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.14] +# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_0_nullable ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', ''))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), has(['hello@posthog.com'], lower(coalesce(events.mat_test_prop, '')))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2899,11 +2859,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.15] +# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_0_nullable.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', '')), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), notIn(lower(coalesce(events.mat_test_prop, '')), tuple('hello@posthog.com'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2919,11 +2879,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.1] +# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_1_non_nullable ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com')), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), has(['hello@posthog.com'], lower(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2939,11 +2899,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.2] +# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_1_non_nullable.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value'))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), notIn(lower(events.mat_test_prop), tuple('hello@posthog.com'))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -2959,12 +2919,23 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.3] +# name: TestMaterializedColumnOptimization.test_lower_in_optimization_on_persons ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value')), 1)) - ORDER BY events.distinct_id ASC + SELECT persons.id AS id, + persons.properties___email AS email + FROM + (SELECT tupleElement(argMax(tuple(person.pmat_email), person.version), 1) AS properties___email, + person.id AS id + FROM person + WHERE and(equals(person.team_id, 99999), in(id, + (SELECT where_optimization.id AS id + FROM person AS where_optimization + WHERE and(equals(where_optimization.team_id, 99999), has(['foo@example.com', 'bar@example.com'], lower(coalesce(where_optimization.pmat_email, ''))))))) + GROUP BY person.id + HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons + WHERE in(lower(persons.properties___email), + ['foo@example.com', 'bar@example.com']) + ORDER BY persons.properties___email ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -2979,12 +2950,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.4] +# name: TestMaterializedColumnOptimization.test_lower_in_uses_bloom_filter_lower_index_on_events ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null'))) - ORDER BY events.distinct_id ASC + SELECT count() AS `count()` + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_bloom_events_test'), has(['foo@example.com', 'bar@example.com'], lower(coalesce(events.mat_email, '')))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -2999,12 +2969,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.5] +# name: TestMaterializedColumnOptimization.test_lower_in_uses_ngram_lower_index_on_events ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null')), 1)) - ORDER BY events.distinct_id ASC + SELECT count() AS `count()` + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_ngram_events_test'), has(['foo@example.com', 'bar@example.com'], lower(coalesce(events.mat_email, '')))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -3019,11 +2988,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.6] +# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_0_nullable ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL'))) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), and(equals(events.mat_test_prop, 'target_value'), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -3039,11 +3008,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.7] +# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_0_nullable.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL')), 1)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), ifNull(notEquals(events.mat_test_prop, 'target_value'), 1)) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -3059,3058 +3028,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.8] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema.9] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_0_no_mat_col[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.10 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has([''], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.11 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.12 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.13 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.14 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', ''], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.15 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.2 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'other_value'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.3 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.4 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.5 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.6 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.7 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.8 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null', 'NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col.9 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.10] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple(''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.11] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.12] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.13] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.14] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', ''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.15] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.2] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.3] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.4] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.5] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.6] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.7] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.8] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema.9] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_1_nullable_mat_col[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com'], events.mat_test_prop)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.10 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple(''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.11 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.12 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.13 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.14 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', ''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.15 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.2 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com', 'other_value'], events.mat_test_prop)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.3 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.4 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.5 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.6 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['NULL'], events.mat_test_prop)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.7 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.8 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col.9 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.10] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple(''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.11] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.12] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.13] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.14] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', ''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.15] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.2] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.3] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.4] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.5] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.6] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.7] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.8] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema.9] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_2_non_nullable_mat_col[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.10 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has([''], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.11 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.12 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.13 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.14 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', ''], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.15 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.2 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['hello@posthog.com', 'other_value'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.3 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.4 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.5 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.6 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.7 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.8 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), and(has(['null', 'NULL'], events.mat_test_prop), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter.9 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(events.mat_test_prop, tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.10] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple(''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.11] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.12] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.13] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.14] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', ''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.15] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.2] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.3] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.4] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.5] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.6] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.7] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.8] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema.9] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_3_nullable_mat_col_with_bloom_filter[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com'], events.mat_test_prop)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.10 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple(''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.11 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.12 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.13 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.14 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', ''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.15 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.2 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['hello@posthog.com', 'other_value'], events.mat_test_prop)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.3 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('hello@posthog.com', 'other_value'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.4 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.5 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.6 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), has(['NULL'], events.mat_test_prop)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.7 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), notIn(events.mat_test_prop, tuple('NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.8 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter.9 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.10] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple(''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.11] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.12] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.13] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.14] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', ''))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.15] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', '')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.2] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.3] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com', 'other_value')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.4] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.5] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.6] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.7] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.8] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema.9] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), ifNull(notIn(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('null', 'NULL')), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_in_and_not_in_optimization_gives_correct_results_4_non_nullable_mat_col_with_bloom_filter[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_in_test'), in(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_0_nullable - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), has(['hello@posthog.com'], lower(coalesce(events.mat_test_prop, '')))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_0_nullable.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), notIn(lower(coalesce(events.mat_test_prop, '')), tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_0_nullable[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), ifNull(notIn(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))))), 'hello@posthog.com'), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_0_nullable[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), in(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))))), 'hello@posthog.com')) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_1_non_nullable - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), has(['hello@posthog.com'], lower(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_1_non_nullable.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), notIn(lower(events.mat_test_prop), tuple('hello@posthog.com'))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_1_non_nullable[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), ifNull(notIn(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))))), 'hello@posthog.com'), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_handles_null_and_sentinel_rows_1_non_nullable[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_lower_in_test'), in(lower(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop)))))), 'hello@posthog.com')) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_optimization_on_persons - ''' - SELECT persons.id AS id, - persons.properties___email AS email - FROM - (SELECT tupleElement(argMax(tuple(person.pmat_email), person.version), 1) AS properties___email, - person.id AS id - FROM person - WHERE and(equals(person.team_id, 99999), in(id, - (SELECT where_optimization.id AS id - FROM person AS where_optimization - WHERE and(equals(where_optimization.team_id, 99999), has(['foo@example.com', 'bar@example.com'], lower(coalesce(where_optimization.pmat_email, ''))))))) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))) AS persons - WHERE in(lower(persons.properties___email), - ['foo@example.com', 'bar@example.com']) - ORDER BY persons.properties___email ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_uses_bloom_filter_lower_index_on_events - ''' - SELECT count() AS `count()` - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_bloom_events_test'), has(['foo@example.com', 'bar@example.com'], lower(coalesce(events.mat_email, '')))) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_uses_bloom_filter_lower_index_on_events[new_events_schema] - ''' - SELECT count() AS `count()` - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_bloom_events_test'), in(lower(if(notEquals(toJSONString(events.properties.^email), '{}'), toJSONString(events.properties.^email), if(isNull(events.properties.email), NULL, if(startsWith(dynamicType(events.properties.email), 'DateTime'), replaceOne(toString(events.properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.email), 'Array'), startsWith(dynamicType(events.properties.email), 'Map'), startsWith(dynamicType(events.properties.email), 'Tuple')), toJSONString(events.properties.email), toString(events.properties.email)))))), ['foo@example.com', 'bar@example.com'])) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_uses_ngram_lower_index_on_events - ''' - SELECT count() AS `count()` - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_ngram_events_test'), has(['foo@example.com', 'bar@example.com'], lower(coalesce(events.mat_email, '')))) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_lower_in_uses_ngram_lower_index_on_events[new_events_schema] - ''' - SELECT count() AS `count()` - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_lower_ngram_events_test'), in(lower(if(notEquals(toJSONString(events.properties.^email), '{}'), toJSONString(events.properties.^email), if(isNull(events.properties.email), NULL, if(startsWith(dynamicType(events.properties.email), 'DateTime'), replaceOne(toString(events.properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.email), 'Array'), startsWith(dynamicType(events.properties.email), 'Map'), startsWith(dynamicType(events.properties.email), 'Tuple')), toJSONString(events.properties.email), toString(events.properties.email)))))), ['foo@example.com', 'bar@example.com'])) - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_0_nullable - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), and(equals(events.mat_test_prop, 'target_value'), isNotNull(events.mat_test_prop))) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_0_nullable.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), ifNull(notEquals(events.mat_test_prop, 'target_value'), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_0_nullable[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), ifNull(notEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'target_value'), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_0_nullable[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), ifNull(equals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'target_value'), 0)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_1_not_nullable - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), equals(events.mat_test_prop, 'target_value')) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_1_not_nullable.1 - ''' - SELECT events.distinct_id AS distinct_id - FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), notEquals(events.mat_test_prop, 'target_value')) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_1_not_nullable[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), ifNull(notEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'target_value'), 1)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_1_not_nullable[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), ifNull(equals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'target_value'), 0)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_0_nullable +# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_1_not_nullable ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), and(less(events.mat_test_prop, 'mango'), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), equals(events.mat_test_prop, 'target_value')) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -6126,11 +3048,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_0_nullable.1 +# name: TestMaterializedColumnOptimization.test_materialized_column_optimization_returns_correct_results_1_not_nullable.1 ''' SELECT events.distinct_id AS distinct_id FROM events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), and(greaterOrEquals(events.mat_test_prop, 'mango'), isNotNull(events.mat_test_prop))) + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_eq_test'), notEquals(events.mat_test_prop, 'target_value')) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -6146,11 +3068,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_0_nullable[new_events_schema.1] +# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_0_nullable ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'mango'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), and(less(events.mat_test_prop, 'mango'), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -6166,11 +3088,11 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_0_nullable[new_events_schema] +# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_0_nullable.1 ''' SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'mango'), 0)) + FROM events + WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), and(greaterOrEquals(events.mat_test_prop, 'mango'), isNotNull(events.mat_test_prop))) ORDER BY events.distinct_id ASC LIMIT 100 SETTINGS readonly=2, max_execution_time=60, @@ -6226,46 +3148,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_1_not_nullable[new_events_schema.1] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(greaterOrEquals(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'mango'), 0)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- -# name: TestMaterializedColumnOptimization.test_materialized_column_range_optimization_returns_correct_results_1_not_nullable[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'mat_col_opt_range_test'), ifNull(less(if(notEquals(toJSONString(events.properties.^test_prop), '{}'), toJSONString(events.properties.^test_prop), if(isNull(events.properties.test_prop), NULL, if(startsWith(dynamicType(events.properties.test_prop), 'DateTime'), replaceOne(toString(events.properties.test_prop), ' ', 'T'), if(or(startsWith(dynamicType(events.properties.test_prop), 'Array'), startsWith(dynamicType(events.properties.test_prop), 'Map'), startsWith(dynamicType(events.properties.test_prop), 'Tuple')), toJSONString(events.properties.test_prop), toString(events.properties.test_prop))))), 'mango'), 0)) - ORDER BY events.distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_0_materialized_joined ''' SELECT events.distinct_id AS distinct_id, @@ -6307,47 +3189,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_0_materialized_joined[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id, - events__person.properties___email AS email_value, - isNull(events__person.properties___email) AS is_not_set_result, - or(isNull(events__person.properties___email), not(JSONHas(events__person.properties, 'email'))) AS is_not_set_result_historical - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - LEFT JOIN - (SELECT person.id AS id, - nullIf(nullIf(person.pmat_email, ''), 'null') AS properties___email, - person.properties AS properties - FROM person - WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version), - (SELECT person.id AS id, max(person.version) AS version - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE and(equals(events.team_id, 99999), equals(events.event, 'is_not_set_test')) - ORDER BY distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_1_materialized_on_events ''' SELECT events.distinct_id AS distinct_id, @@ -6371,29 +3212,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_1_materialized_on_events[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id, - if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))) AS email_value, - isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email)))))) AS is_not_set_result, - or(isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email)))))), not(or(isNotNull(events.person_properties.email), notEquals(toJSONString(events.person_properties.^email), '{}')))) AS is_not_set_result_historical - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'is_not_set_test')) - ORDER BY distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_2_not_materialized_joined ''' SELECT events.distinct_id AS distinct_id, @@ -6435,47 +3253,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_2_not_materialized_joined[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id, - events__person.properties___email AS email_value, - isNull(events__person.properties___email) AS is_not_set_result, - or(isNull(events__person.properties___email), not(JSONHas(events__person.properties, 'email'))) AS is_not_set_result_historical - FROM events_json AS events - LEFT OUTER JOIN - (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, - person_distinct_id_overrides.distinct_id AS distinct_id - FROM person_distinct_id_overrides - WHERE equals(person_distinct_id_overrides.team_id, 99999) - GROUP BY person_distinct_id_overrides.distinct_id - HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) - LEFT JOIN - (SELECT person.id AS id, - replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(person.properties, 'email'), ''), 'null'), '^"|"$', '') AS properties___email, - person.properties AS properties - FROM person - WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version), - (SELECT person.id AS id, max(person.version) AS version - FROM person - WHERE equals(person.team_id, 99999) - GROUP BY person.id - HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE and(equals(events.team_id, 99999), equals(events.event, 'is_not_set_test')) - ORDER BY distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_3_not_materialized_on_events ''' SELECT events.distinct_id AS distinct_id, @@ -6499,29 +3276,6 @@ use_hive_partitioning=0 ''' # --- -# name: TestMaterializedColumnOptimization.test_person_property_is_not_set_behavior_3_not_materialized_on_events[new_events_schema] - ''' - SELECT events.distinct_id AS distinct_id, - if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email))))) AS email_value, - isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email)))))) AS is_not_set_result, - or(isNull(if(notEquals(toJSONString(events.person_properties.^email), '{}'), toJSONString(events.person_properties.^email), if(isNull(events.person_properties.email), NULL, if(startsWith(dynamicType(events.person_properties.email), 'DateTime'), replaceOne(toString(events.person_properties.email), ' ', 'T'), if(or(startsWith(dynamicType(events.person_properties.email), 'Array'), startsWith(dynamicType(events.person_properties.email), 'Map'), startsWith(dynamicType(events.person_properties.email), 'Tuple')), toJSONString(events.person_properties.email), toString(events.person_properties.email)))))), not(or(isNotNull(events.person_properties.email), notEquals(toJSONString(events.person_properties.^email), '{}')))) AS is_not_set_result_historical - FROM events_json AS events - WHERE and(equals(events.team_id, 99999), equals(events.event, 'is_not_set_test')) - ORDER BY distinct_id ASC - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - optimize_rewrite_aggregate_function_with_if=0, - optimize_min_inequality_conjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# --- # name: TestPrinter.test_large_pretty_print ''' SELECT @@ -6593,218 +3347,75 @@ LIMIT 50000 ''' # --- -# name: TestPrinter.test_large_pretty_print[new_events_schema] - ''' - SELECT - groupArray(start_of_period) AS date, - groupArray(counts) AS total, - status - FROM - (SELECT - if(equals(status, 'dormant'), negate(sum(counts)), negate(negate(sum(counts)))) AS counts, - start_of_period, - status - FROM - (SELECT - periods.start_of_period AS start_of_period, - 0 AS counts, - status - FROM - (SELECT - minus(dateTrunc('day', assumeNotNull(toDateTime('2023-10-19 23:59:59'))), toIntervalDay(number)) AS start_of_period - FROM - numbers(dateDiff('day', dateTrunc('day', assumeNotNull(toDateTime('2023-09-19 00:00:00'))), dateTrunc('day', plus(assumeNotNull(toDateTime('2023-10-19 23:59:59')), toIntervalDay(1))))) AS numbers) AS periods - CROSS JOIN (SELECT - status - FROM - (SELECT - 1) - ARRAY JOIN ['new', 'returning', 'resurrecting', 'dormant'] AS status) AS sec - ORDER BY - status ASC, - start_of_period ASC - UNION ALL - SELECT - start_of_period, - count(DISTINCT person_id) AS counts, - status - FROM - (SELECT - events.person.id AS person_id, - min(events.person.created_at) AS created_at, - arraySort(groupUniqArray(dateTrunc('day', events.timestamp))) AS all_activity, - arrayPopBack(arrayPushFront(all_activity, dateTrunc('day', created_at))) AS previous_activity, - arrayPopFront(arrayPushBack(all_activity, dateTrunc('day', toDateTime('1970-01-01 00:00:00')))) AS following_activity, - arrayMap((previous, current, index) -> if(equals(previous, current), 'new', if(and(equals(minus(current, toIntervalDay(1)), previous), notEquals(index, 1)), 'returning', 'resurrecting')), previous_activity, all_activity, arrayEnumerate(all_activity)) AS initial_status, - arrayMap((current, next) -> if(equals(plus(current, toIntervalDay(1)), next), '', 'dormant'), all_activity, following_activity) AS dormant_status, - arrayMap(x -> plus(x, toIntervalDay(1)), arrayFilter((current, is_dormant) -> equals(is_dormant, 'dormant'), all_activity, dormant_status)) AS dormant_periods, - arrayMap(x -> 'dormant', dormant_periods) AS dormant_label, - arrayConcat(arrayZip(all_activity, initial_status), arrayZip(dormant_periods, dormant_label)) AS temp_concat, - arrayJoin(temp_concat) AS period_status_pairs, - period_status_pairs.1 AS start_of_period, - period_status_pairs.2 AS status - FROM - events - WHERE - and(greaterOrEquals(timestamp, minus(dateTrunc('day', assumeNotNull(toDateTime('2023-09-19 00:00:00'))), toIntervalDay(1))), less(timestamp, plus(dateTrunc('day', assumeNotNull(toDateTime('2023-10-19 23:59:59'))), toIntervalDay(1))), equals(event, '$pageview')) - GROUP BY - person_id) - GROUP BY - start_of_period, - status) - WHERE - and(lessOrEquals(start_of_period, dateTrunc('day', assumeNotNull(toDateTime('2023-10-19 23:59:59')))), greaterOrEquals(start_of_period, dateTrunc('day', assumeNotNull(toDateTime('2023-09-19 00:00:00'))))) - GROUP BY - start_of_period, - status - ORDER BY - start_of_period ASC) - GROUP BY - status - LIMIT 50000 - ''' -# --- # name: TestPrinter.test_projection_pushdown_nested_subqueries_0_with_optimize_projections 'SELECT outer.event AS event FROM (SELECT inner.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_3)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_4)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_nested_subqueries_0_with_optimize_projections[new_events_schema] - 'SELECT outer.event AS event FROM (SELECT inner.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_1)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_2)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000' -# --- # name: TestPrinter.test_projection_pushdown_nested_subqueries_1_without_optimize_projections 'SELECT outer.event AS event FROM (SELECT inner.uuid AS uuid, inner.event AS event, inner.properties AS properties, inner.timestamp AS timestamp, inner.distinct_id AS distinct_id, inner.elements_chain AS elements_chain, inner.created_at AS created_at, inner.`$session_id` AS `$session_id`, inner.`$window_id` AS `$window_id`, inner.person_mode AS person_mode, inner.person_id AS person_id, inner.`$group_0` AS `$group_0`, inner.`$group_1` AS `$group_1`, inner.`$group_2` AS `$group_2`, inner.`$group_3` AS `$group_3`, inner.`$group_4` AS `$group_4`, inner.elements_chain_href AS elements_chain_href, inner.elements_chain_texts AS elements_chain_texts, inner.elements_chain_ids AS elements_chain_ids, inner.elements_chain_elements AS elements_chain_elements, inner.event_person_id AS event_person_id, inner.event_issue_id AS event_issue_id, inner.issue_id AS issue_id, inner.issue_id_v2 AS issue_id_v2, inner.issue_name AS issue_name, inner.issue_description AS issue_description, inner.issue_status AS issue_status, inner.issue_assigned_user_id AS issue_assigned_user_id, inner.issue_assigned_role_id AS issue_assigned_role_id, inner.issue_first_seen AS issue_first_seen FROM (SELECT events.uuid AS uuid, events.event AS event, events.properties AS properties, toTimeZone(events.timestamp, %(hogql_val_3)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_4)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_7)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_8)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_nested_subqueries_1_without_optimize_projections[new_events_schema] - "SELECT outer.event AS event FROM (SELECT inner.uuid AS uuid, inner.event AS event, inner.properties AS properties, inner.timestamp AS timestamp, inner.distinct_id AS distinct_id, inner.elements_chain AS elements_chain, inner.created_at AS created_at, inner.`$session_id` AS `$session_id`, inner.`$window_id` AS `$window_id`, inner.person_mode AS person_mode, inner.person_id AS person_id, inner.`$group_0` AS `$group_0`, inner.`$group_1` AS `$group_1`, inner.`$group_2` AS `$group_2`, inner.`$group_3` AS `$group_3`, inner.`$group_4` AS `$group_4`, inner.elements_chain_href AS elements_chain_href, inner.elements_chain_texts AS elements_chain_texts, inner.elements_chain_ids AS elements_chain_ids, inner.elements_chain_elements AS elements_chain_elements, inner.event_person_id AS event_person_id, inner.event_issue_id AS event_issue_id, inner.issue_id AS issue_id, inner.issue_id_v2 AS issue_id_v2, inner.issue_name AS issue_name, inner.issue_description AS issue_description, inner.issue_status AS issue_status, inner.issue_assigned_user_id AS issue_assigned_user_id, inner.issue_assigned_role_id AS issue_assigned_role_id, inner.issue_first_seen AS issue_first_seen FROM (SELECT events.uuid AS uuid, events.event AS event, concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null' AND NOT (kv.2 = '[]' AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_3)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_4)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS inner) AS outer LIMIT 50000" -# --- # name: TestPrinter.test_projection_pushdown_no_asterisk_unchanged_0_with_optimize_projections 'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id FROM events WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_no_asterisk_unchanged_0_with_optimize_projections[new_events_schema] - 'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id FROM events_json AS events WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000' -# --- # name: TestPrinter.test_projection_pushdown_no_asterisk_unchanged_1_without_optimize_projections 'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id FROM events WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_no_asterisk_unchanged_1_without_optimize_projections[new_events_schema] - 'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id FROM events_json AS events WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000' -# --- # name: TestPrinter.test_projection_pushdown_preserves_join_columns_0_with_optimize_projections 'SELECT e.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_3)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_4)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_7)s), person.version), plus(now64(6, %(hogql_val_8)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_preserves_join_columns_0_with_optimize_projections[new_events_schema] - 'SELECT e.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_1)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_2)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_3)s), person.version), plus(now64(6, %(hogql_val_4)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000' -# --- # name: TestPrinter.test_projection_pushdown_preserves_join_columns_1_without_optimize_projections 'SELECT e.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, events.properties AS properties, toTimeZone(events.timestamp, %(hogql_val_3)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_4)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_7)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_8)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_9)s), person.version), plus(now64(6, %(hogql_val_10)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_preserves_join_columns_1_without_optimize_projections[new_events_schema] - "SELECT e.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null' AND NOT (kv.2 = '[]' AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_3)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_4)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS e LEFT JOIN (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_5)s), person.version), plus(now64(6, %(hogql_val_6)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS persons ON equals(persons.id, e.person_id) LIMIT 50000" -# --- # name: TestPrinter.test_projection_pushdown_preserves_where_columns_0_with_optimize_projections 'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_3)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_4)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_7)s) LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_preserves_where_columns_0_with_optimize_projections[new_events_schema] - 'SELECT sub.event AS event FROM (SELECT events.event AS event, events.distinct_id AS distinct_id, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_1)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_2)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_3)s) LIMIT 50000' -# --- # name: TestPrinter.test_projection_pushdown_preserves_where_columns_1_without_optimize_projections 'SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, events.properties AS properties, toTimeZone(events.timestamp, %(hogql_val_3)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_4)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_7)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_8)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_9)s) LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_preserves_where_columns_1_without_optimize_projections[new_events_schema] - "SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null' AND NOT (kv.2 = '[]' AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_3)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_4)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub WHERE equals(sub.distinct_id, %(hogql_val_5)s) LIMIT 50000" -# --- # name: TestPrinter.test_projection_pushdown_simple_asterisk_subquery_0_with_optimize_projections 'SELECT sub.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_3)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_4)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_simple_asterisk_subquery_0_with_optimize_projections[new_events_schema] - 'SELECT sub.event AS event FROM (SELECT events.event AS event, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_1)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_2)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000' -# --- # name: TestPrinter.test_projection_pushdown_simple_asterisk_subquery_1_without_optimize_projections 'SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, events.properties AS properties, toTimeZone(events.timestamp, %(hogql_val_3)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_4)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_5)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_6)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_7)s), \'\'), \'null\'), \'^"|"$\', \'\'), %(hogql_val_8)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_1)s), \'\'), \'null\'), \'^"|"$\', \'\')), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_2)s), \'\'), \'null\'), \'^"|"$\', \'\'), events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000' # --- -# name: TestPrinter.test_projection_pushdown_simple_asterisk_subquery_1_without_optimize_projections[new_events_schema] - "SELECT sub.event AS event FROM (SELECT events.uuid AS uuid, events.event AS event, concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), arrayFilter(kv -> kv.2 != 'null' AND NOT (kv.2 = '[]' AND has(['$active_feature_flags', '$exception_functions', '$exception_sources', '$exception_types', '$exception_values'], kv.1)), JSONExtractKeysAndValuesRaw(toJSONString(events.properties)))), ','), '}') AS properties, toTimeZone(events.timestamp, %(hogql_val_1)s) AS timestamp, events.distinct_id AS distinct_id, events.elements_chain AS elements_chain, toTimeZone(events.created_at, %(hogql_val_2)s) AS created_at, events.`$session_id` AS `$session_id`, events.`$window_id` AS `$window_id`, events.person_mode AS person_mode, if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS person_id, events.`$group_0` AS `$group_0`, events.`$group_1` AS `$group_1`, events.`$group_2` AS `$group_2`, events.`$group_3` AS `$group_3`, events.`$group_4` AS `$group_4`, events.elements_chain_href AS elements_chain_href, events.elements_chain_texts AS elements_chain_texts, events.elements_chain_ids AS elements_chain_ids, events.elements_chain_elements AS elements_chain_elements, events.person_id AS event_person_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_3)s) AS event_issue_id, if(not(empty(events__exception_issue_override.issue_id)), events__exception_issue_override.issue_id, accurateCastOrNull(events.properties.`$exception_issue_id`, %(hogql_val_4)s)) AS issue_id, events__fingerprint_issue_state.issue_id AS issue_id_v2, events__fingerprint_issue_state.issue_name AS issue_name, events__fingerprint_issue_state.issue_description AS issue_description, events__fingerprint_issue_state.issue_status AS issue_status, events__fingerprint_issue_state.assigned_user_id AS issue_assigned_user_id, events__fingerprint_issue_state.assigned_role_id AS issue_assigned_role_id, events__fingerprint_issue_state.first_seen AS issue_first_seen FROM events_json AS events LEFT OUTER JOIN (SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_id), error_tracking_fingerprint_issue_state.version), 1)) AS issue_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_name), error_tracking_fingerprint_issue_state.version), 1)) AS issue_name, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_description), error_tracking_fingerprint_issue_state.version), 1)) AS issue_description, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.issue_status), error_tracking_fingerprint_issue_state.version), 1)) AS issue_status, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_user_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_user_id, toNullable(tupleElement(argMax(tuple(error_tracking_fingerprint_issue_state.assigned_role_id), error_tracking_fingerprint_issue_state.version), 1)) AS assigned_role_id, toNullable(tupleElement(argMax(tuple(toTimeZone(error_tracking_fingerprint_issue_state.first_seen, %(hogql_val_0)s)), error_tracking_fingerprint_issue_state.version), 1)) AS first_seen FROM error_tracking_fingerprint_issue_state WHERE equals(error_tracking_fingerprint_issue_state.team_id, 99999) GROUP BY fp_hash HAVING equals(argMax(error_tracking_fingerprint_issue_state.is_deleted, error_tracking_fingerprint_issue_state.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__fingerprint_issue_state ON equals(cityHash64(events.properties.`$exception_fingerprint`), events__fingerprint_issue_state.fp_hash) LEFT OUTER JOIN (SELECT argMax(error_tracking_issue_fingerprint_overrides.issue_id, error_tracking_issue_fingerprint_overrides.version) AS issue_id, error_tracking_issue_fingerprint_overrides.fingerprint AS fingerprint FROM error_tracking_issue_fingerprint_overrides WHERE equals(error_tracking_issue_fingerprint_overrides.team_id, 99999) GROUP BY error_tracking_issue_fingerprint_overrides.fingerprint HAVING equals(argMax(error_tracking_issue_fingerprint_overrides.is_deleted, error_tracking_issue_fingerprint_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__exception_issue_override ON equals(events.properties.`$exception_fingerprint`, events__exception_issue_override.fingerprint) LEFT OUTER JOIN (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id FROM person_distinct_id_overrides WHERE equals(person_distinct_id_overrides.team_id, 99999) GROUP BY person_distinct_id_overrides.distinct_id HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id) WHERE equals(events.team_id, 99999)) AS sub LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_anonymous_tables_0_global_joins_with_optimize "SELECT e.event AS event, ij.remote_id AS remote_id FROM events AS e GLOBAL INNER JOIN (SELECT remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_anonymous_tables_0_global_joins_with_optimize[new_events_schema] - "SELECT e.event AS event, ij.remote_id AS remote_id FROM events_json AS e GLOBAL INNER JOIN (SELECT remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_anonymous_tables_1_global_joins_without_optimize "SELECT e.event AS event, ij.remote_id AS remote_id FROM events AS e GLOBAL INNER JOIN (SELECT person_id AS person_id, remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_anonymous_tables_1_global_joins_without_optimize[new_events_schema] - "SELECT e.event AS event, ij.remote_id AS remote_id FROM events_json AS e GLOBAL INNER JOIN (SELECT person_id AS person_id, remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_anonymous_tables_2_no_global_joins_with_optimize "SELECT e.event AS event, ij.remote_id AS remote_id FROM events AS e INNER JOIN (SELECT remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_anonymous_tables_2_no_global_joins_with_optimize[new_events_schema] - "SELECT e.event AS event, ij.remote_id AS remote_id FROM events_json AS e INNER JOIN (SELECT remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_anonymous_tables_3_no_global_joins_without_optimize "SELECT e.event AS event, ij.remote_id AS remote_id FROM events AS e INNER JOIN (SELECT person_id AS person_id, remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_anonymous_tables_3_no_global_joins_without_optimize[new_events_schema] - "SELECT e.event AS event, ij.remote_id AS remote_id FROM events_json AS e INNER JOIN (SELECT person_id AS person_id, remote_id AS remote_id FROM (SELECT p.id AS person_id, rt.id AS remote_id FROM (SELECT person.id AS id FROM person WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(equals(argMax(person.is_deleted, person.version), 0), less(argMax(toTimeZone(person.created_at, %(hogql_val_0)s), person.version), plus(now64(6, %(hogql_val_1)s), toIntervalDay(1)))) SETTINGS optimize_aggregation_in_order=1) AS p LEFT JOIN (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_2_sensitive)s, %(hogql_val_4_sensitive)s, %(hogql_val_5_sensitive)s, 'Parquet', %(hogql_val_3)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) AS rt ON equals(rt.id, p.id))) AS ij ON equals(e.event, ij.remote_id) WHERE equals(e.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_cte_0_global_joins_with_optimize "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events GLOBAL JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_cte_0_global_joins_with_optimize[new_events_schema] - "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events_json AS events GLOBAL JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_cte_1_global_joins_without_optimize "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events GLOBAL JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_cte_1_global_joins_without_optimize[new_events_schema] - "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events_json AS events GLOBAL JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_cte_2_no_global_joins_with_optimize "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_cte_2_no_global_joins_with_optimize[new_events_schema] - "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events_json AS events JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_cte_3_no_global_joins_without_optimize "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_cte_3_no_global_joins_without_optimize[new_events_schema] - "WITH some_remote_table AS (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table) SELECT events.event AS event FROM events_json AS events JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_cte_nested_0 "WITH some_remote_table AS (SELECT e.event AS event, t.id AS id FROM events AS e GLOBAL JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(toString(t.id), e.event) WHERE equals(e.team_id, 99999)) SELECT some_remote_table.event AS event FROM events GLOBAL JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_cte_nested_0[new_events_schema] - "WITH some_remote_table AS (SELECT e.event AS event, t.id AS id FROM events_json AS e GLOBAL JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(toString(t.id), e.event) WHERE equals(e.team_id, 99999)) SELECT some_remote_table.event AS event FROM events_json AS events GLOBAL JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_cte_nested_1 "WITH some_remote_table AS (SELECT e.event AS event, t.id AS id FROM events AS e JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(toString(t.id), e.event) WHERE equals(e.team_id, 99999)) SELECT some_remote_table.event AS event FROM events JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_cte_nested_1[new_events_schema] - "WITH some_remote_table AS (SELECT e.event AS event, t.id AS id FROM events_json AS e JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(toString(t.id), e.event) WHERE equals(e.team_id, 99999)) SELECT some_remote_table.event AS event FROM events_json AS events JOIN some_remote_table ON equals(events.event, toString(some_remote_table.id)) WHERE equals(events.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_in_and_property_type_0 'SELECT events.event AS event FROM events WHERE and(equals(events.team_id, 99999), ifNull(globalIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), \'\'), \'null\'), \'^"|"$\', \'\'), (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_1_sensitive)s, %(hogql_val_3_sensitive)s, %(hogql_val_4_sensitive)s, \'Parquet\', %(hogql_val_2)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table)), 0)) LIMIT 50000' # --- -# name: TestPrinter.test_s3_tables_global_join_with_in_and_property_type_0[new_events_schema] - "SELECT events.event AS event FROM events_json AS events WHERE and(equals(events.team_id, 99999), ifNull(globalIn(events.properties.`$browser`, (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table)), 0)) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_in_and_property_type_1 'SELECT events.event AS event FROM events WHERE and(equals(events.team_id, 99999), in(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), \'\'), \'null\'), \'^"|"$\', \'\'), (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_1_sensitive)s, %(hogql_val_3_sensitive)s, %(hogql_val_4_sensitive)s, \'Parquet\', %(hogql_val_2)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table))) LIMIT 50000' # --- -# name: TestPrinter.test_s3_tables_global_join_with_in_and_property_type_1[new_events_schema] - "SELECT events.event AS event FROM events_json AS events WHERE and(equals(events.team_id, 99999), in(events.properties.`$browser`, (SELECT test_table.id AS id FROM (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS test_table))) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_multiple_joins_0 "SELECT e.event, s.event AS event, t.id AS id FROM events AS e GLOBAL JOIN (SELECT events.event AS event FROM events WHERE equals(events.team_id, 99999)) AS s ON equals(e.event, s.event) GLOBAL LEFT JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(e.event, toString(t.id)) WHERE equals(e.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_multiple_joins_0[new_events_schema] - "SELECT e.event, s.event AS event, t.id AS id FROM events_json AS e GLOBAL JOIN (SELECT events.event AS event FROM events_json AS events WHERE equals(events.team_id, 99999)) AS s ON equals(e.event, s.event) GLOBAL LEFT JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(e.event, toString(t.id)) WHERE equals(e.team_id, 99999) LIMIT 50000" -# --- # name: TestPrinter.test_s3_tables_global_join_with_multiple_joins_1 "SELECT e.event, s.event AS event, t.id AS id FROM events AS e JOIN (SELECT events.event AS event FROM events WHERE equals(events.team_id, 99999)) AS s ON equals(e.event, s.event) LEFT JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(e.event, toString(t.id)) WHERE equals(e.team_id, 99999) LIMIT 50000" # --- -# name: TestPrinter.test_s3_tables_global_join_with_multiple_joins_1[new_events_schema] - "SELECT e.event, s.event AS event, t.id AS id FROM events_json AS e JOIN (SELECT events.event AS event FROM events_json AS events WHERE equals(events.team_id, 99999)) AS s ON equals(e.event, s.event) LEFT JOIN (SELECT * FROM s3(%(hogql_val_0_sensitive)s, %(hogql_val_2_sensitive)s, %(hogql_val_3_sensitive)s, 'Parquet', %(hogql_val_1)s) SETTINGS optimize_move_to_prewhere = 0) AS t ON equals(e.event, toString(t.id)) WHERE equals(e.team_id, 99999) LIMIT 50000" -# --- diff --git a/posthog/hogql/test/__snapshots__/test_mapping.ambr b/posthog/hogql/test/__snapshots__/test_mapping.ambr index cd4d71372c7d..e0c8d1ab273f 100644 --- a/posthog/hogql/test/__snapshots__/test_mapping.ambr +++ b/posthog/hogql/test/__snapshots__/test_mapping.ambr @@ -332,21 +332,3 @@ 'medianArgMaxOrNullIf: (3, 3)', ]) # --- -# name: TestMappings.test_postgres_functions_snapshot - ''' - WITH date_functions AS - (SELECT toDateTime(fromUnixTimestamp(1672579532)) AS to_timestamp_result) - SELECT toTimeZone(date_functions.to_timestamp_result, 'UTC') AS to_timestamp_result - FROM date_functions - LIMIT 100 SETTINGS readonly=2, - max_execution_time=60, - allow_experimental_object_type=1, - max_ast_elements=4000000, - max_expanded_ast_elements=4000000, - max_bytes_before_external_group_by=0, - transform_null_in=1, - optimize_min_equality_disjunction_chain_length=4294967295, - allow_experimental_join_condition=1, - use_hive_partitioning=0 - ''' -# ---