:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(clickhouse): update native JSON events schema (#91515)
Rory Shanks580c3019bd4e
diff --git a/docs/internal/clickhouse-deletion-coverage.md b/docs/internal/clickhouse-deletion-coverage.mdindex c97628d81c7a..c715018562a4 100644--- a/docs/internal/clickhouse-deletion-coverage.md+++ b/docs/internal/clickhouse-deletion-coverage.md@@ -91,10 +91,14 @@ Skipping one of those tables is worse than under-deleting: the overrides that re## Covered tables- `sharded_events` — all sweeps.-- `sharded_events_json` — all sweeps, but `deletes_job` skips it by default today. Optional: only present after the native-JSON migration. See the known gap below.+- `sharded_events_json` — person, team, queued-uuid and event removal, but `deletes_job` skips it by default today. Property rewriting is unsupported: temporary properties and quarantine diagnostics retain additional copies that the legacy property-removal machinery does not rewrite. Optional: only present after the native-JSON migration. See the known gap below.- `sharded_flag_evaluations` — person, team, queued-uuid and event removal. Not property removal (below). Optional.- `sharded_posthog_document_embeddings_<model>` — event and team deletion, through `delete_event_documents`. An embedded document is keyed by the id of the thing it describes (`document_id`), and an Event deletion's key is that same id, so the pending dictionary is joined on `(team_id, Event, document_id)`. Every per-model table listed by the error tracking facade's `document_embedding_tables` is swept and counted.+Native property-removal requests fail when the selected rows retain a requested permanent or temporary property, or a matching person `$set`/`$set_once` instruction.+They also fail when that property class has quarantine diagnostics, because malformed raw data cannot prove that the requested value is absent.+The gate runs before shard processing and again during verification, with the same event, time-range, and insertion-marker bounds.+## Tables on TTL aloneListed in `TTL_ONLY_TABLES`.diff --git a/docs/internal/clickhouse-utility-udfs.md b/docs/internal/clickhouse-utility-udfs.mdindex ea993acc3af3..fac1e759dbd4 100644--- a/docs/internal/clickhouse-utility-udfs.md+++ b/docs/internal/clickhouse-utility-udfs.md@@ -70,6 +70,9 @@ Both functions use the same executable. The temporary entry point uses `--temporDocuments exceeding the shared depth limit produce `{}` in the temporary output; the permanent cleaner quarantines the original document.+Native events retain `temporary_properties` for 60 days after insertion, including historical events; TTL merges clear the column asynchronously.+Fresh installations use the updated schema definitions. Existing tables require a manual schema rollout and feature-flag query compatibility before native reads are enabled.+### Benchmarking the cleaner`BenchmarkProcessFixture` measures cleaning with a reused processor and output buffer.diff --git a/ee/hogai/chat_agent/query_planner/test/test_toolkit.py b/ee/hogai/chat_agent/query_planner/test/test_toolkit.pyindex b7772611dac2..99c211b07077 100644--- a/ee/hogai/chat_agent/query_planner/test/test_toolkit.py+++ b/ee/hogai/chat_agent/query_planner/test/test_toolkit.py@@ -5,6 +5,8 @@ import time_machinefrom posthog.test.base import APIBaseTest, BaseTest, ClickhouseTestMixin, _create_event, _create_personfrom unittest.mock import patch+from django.conf import settings+from parameterized import parameterizedfrom posthog.schema import CachedActorsPropertyTaxonomyQueryResponse, CachedEventTaxonomyQueryResponse@@ -511,6 +513,9 @@ class TestTaxonomyAgentToolkit(ClickhouseTestMixin, APIBaseTest):def test_retrieve_event_or_action_property_values(self):self._create_taxonomy()toolkit = DummyToolkit(self.team, self.user)+ expected_date = datetime(2024, 1, 1).isoformat(+ sep=" " if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else "T"+ )for item in ("event1", self.action.id):self.assertIn('"Chrome"', toolkit.retrieve_event_or_action_property_values(item, "$browser"))@@ -522,7 +527,7 @@ class TestTaxonomyAgentToolkit(ClickhouseTestMixin, APIBaseTest):)self.assertEqual(toolkit.retrieve_event_or_action_property_values(item, "date"),- f'"{datetime(2024, 1, 1).isoformat()}"',+ f'"{expected_date}"',)@patch.object(DummyToolkit, "_retrieve_event_or_action_taxonomy")diff --git a/posthog/clickhouse/events_json.py b/posthog/clickhouse/events_json.pyindex 62222b022d7b..4df827e8f935 100644--- a/posthog/clickhouse/events_json.py+++ b/posthog/clickhouse/events_json.py@@ -12,236 +12,597 @@ EVENTS_JSON_DATA_TABLE = "sharded_events_json"WRITABLE_EVENTS_JSON_TABLE = "writable_events_json"DISTRIBUTED_EVENTS_JSON_TABLE = "events_json"KAFKA_EVENTS_NATIVE_JSON_TABLE = "kafka_events_json_native_json"+UNPARSEABLE_PROPERTIES_KEY = "$unparseable_properties"-def _json_subcolumn_type_supports_nullable(column_type: str) -> bool:- return not column_type.startswith(("Array(", "Map("))---def _nullable_json_subcolumn_types(subcolumns: dict[str, str]) -> dict[str, str]:- return {- path: column_type- if column_type.startswith("Nullable(") or not _json_subcolumn_type_supports_nullable(column_type)- else f"Nullable({column_type})"- for path, column_type in subcolumns.items()- }---# Scalar JSON subcolumns are wrapped as Nullable so missing/JSON-null values stay distinct from scalar defaults such as-# an empty string. Arrays and maps stay non-nullable because ClickHouse does not support Nullable(Array(...)) or-# Nullable(Map(...)).EVENTS_PROPERTIES_JSON_SUBCOLUMN_DECLARED_TYPES: dict[str, str] = {- "$active_feature_flags": "Array(String)",- "$ai_experiment_id": "Nullable(String)",- "$ai_http_status": "Nullable(String)",- "$ai_is_error": "Nullable(String)",- "$ai_model": "Nullable(String)",- "$ai_parent_id": "Nullable(String)",- "$ai_prompt_name": "Nullable(String)",- "$ai_provider": "Nullable(String)",- "$ai_session_id": "Nullable(String)",- "$ai_span_id": "Nullable(String)",- "$ai_total_cost_usd": "Nullable(String)",- "$ai_trace_id": "Nullable(String)",- "$anon_distinct_id": "Nullable(String)",+ "$agent_application_id": "String",+ "$agent_revision_id": "String",+ "$agent_session_id": "String",+ "$agent_turn": "String",+ "$ai_audio_cost_usd": "String",+ "$ai_audio_input_tokens": "String",+ "$ai_audio_output_tokens": "String",+ "$ai_batch_run_id": "String",+ "$ai_cache_creation_input_tokens": "String",+ "$ai_cache_read_input_tokens": "String",+ "$ai_error": "String",+ "$ai_error_normalized": "String",+ "$ai_error_type": "String",+ "$ai_evaluation_allows_na": "String",+ "$ai_evaluation_applicable": "String",+ "$ai_evaluation_id": "String",+ "$ai_evaluation_name": "String",+ "$ai_evaluation_reasoning": "String",+ "$ai_evaluation_result": "String",+ "$ai_evaluation_result_type": "String",+ "$ai_evaluation_runtime": "String",+ "$ai_evaluation_skipped": "String",+ "$ai_evaluation_start_time": "String",+ "$ai_evaluation_type": "String",+ "$ai_experiment_id": "String",+ "$ai_framework": "String",+ "$ai_generation_id": "String",+ "$ai_http_status": "String",+ "$ai_image_cost_usd": "String",+ "$ai_image_input_tokens": "String",+ "$ai_image_output_tokens": "String",+ "$ai_input_cost_usd": "String",+ "$ai_input_tokens": "String",+ "$ai_is_error": "String",+ "$ai_latency": "String",+ "$ai_model": "String",+ "$ai_output_cost_usd": "String",+ "$ai_output_tokens": "String",+ "$ai_parent_id": "String",+ "$ai_prompt_name": "String",+ "$ai_provider": "String",+ "$ai_reasoning_tokens": "String",+ "$ai_request_cost_usd": "String",+ "$ai_session_id": "String",+ "$ai_span_name": "String",+ "$ai_span_type": "String",+ "$ai_span_id": "String",+ "$ai_sentiment_label": "String",+ "$ai_sentiment_message_count": "String",+ "$ai_sentiment_score": "String",+ "$ai_target_event_id": "String",+ "$ai_text_input_tokens": "String",+ "$ai_text_output_tokens": "String",+ "$ai_time_to_first_token": "String",+ "$ai_total_cost_usd": "String",+ "$ai_total_tokens": "String",+ "$ai_tools_called": "String",+ "$ai_trace_id": "String",+ "$ai_trace_name": "String",+ "$ai_video_cost_usd": "String",+ "$ai_video_input_tokens": "String",+ "$ai_video_output_tokens": "String",+ "$ai_web_search_cost_usd": "String",+ "$ai_web_search_count": "String",+ "$ai_origin": "String",+ "$anon_distinct_id": "String","$app_build": "String",+ "$app_name": "String","$app_namespace": "String","$app_version": "String",- "$browser": "String",- "$browser_version": "String",+ "$autocapture_disabled_server_side": "LowCardinality(String)",+ "$browser": "LowCardinality(String)",+ "$browser_language": "LowCardinality(String)",+ "$browser_language_prefix": "String",+ "$browser_type": "String",+ "$browser_version": "LowCardinality(String)",+ "$config_defaults": "LowCardinality(String)",+ "$configured_session_timeout_ms": "String","$current_url": "String",+ "$dead_clicks_enabled_server_side": "LowCardinality(String)","$device": "String","$device_id": "String","$device_model": "String",- "$device_type": "String",+ "$device_manufacturer": "String",+ "$device_name": "String",+ "$device_type": "LowCardinality(String)","$el_text": "String","$event_type": "String",- "$exception_fingerprint": "Nullable(String)",+ "$exception_capture_enabled_server_side": "LowCardinality(String)",+ "$exception_fingerprint": "String","$exception_functions": "Array(String)",- "$exception_issue_id": "Nullable(String)",+ "$exception_handled": "String",+ "$exception_is_synthetic": "String",+ "$exception_issue_id": "String",+ "$exception_level": "String",+ "$exception_list": "Array(JSON(max_dynamic_paths = 0, type String, value String))",+ "$exception_message": "String",+ "$exception_proposed_fingerprint": "String","$exception_sources": "Array(String)",+ "$exception_type": "String","$exception_types": "Array(String)","$exception_values": "Array(String)",- "$feature_flag": "String",- "$feature_flag_payloads": "String",- "$feature_flag_response": "String",- "$geoip_city_name": "String",- "$geoip_country_code": "String",- "$geoip_country_name": "String",+ "$feature_flags": "Map(LowCardinality(String), LowCardinality(String))",+ "$geoip_accuracy_radius": "String",+ "$geoip_city_name": "LowCardinality(String)",+ "$geoip_continent_code": "LowCardinality(String)",+ "$geoip_continent_name": "LowCardinality(String)",+ "$geoip_country_code": "LowCardinality(String)",+ "$geoip_country_name": "LowCardinality(String)",+ "$geoip_latitude": "String",+ "$geoip_longitude": "String",+ "$geoip_postal_code": "String",+ "$geoip_subdivision_1_name": "LowCardinality(String)",+ "$geoip_subdivision_2_code": "String",+ "$geoip_subdivision_2_name": "String",+ "$geoip_time_zone": "LowCardinality(String)","$geoip_subdivision_1_code": "String","$group_0": "String","$group_1": "String","$group_2": "String","$group_3": "String","$group_4": "String",- "$groups": "String",+ "$groups.organization": "String",+ "$groups.project": "String",+ "$groups.instance": "String","$host": "String","$initial_pathname": "String","$initial_referrer": "String","$initial_referring_domain": "String",+ "$client_session_initial_pathname": "String",+ "$client_session_initial_referring_host": "String",+ "$client_session_initial_utm_campaign": "String",+ "$client_session_initial_utm_content": "String",+ "$client_session_initial_utm_medium": "String",+ "$client_session_initial_utm_source": "String",+ "$client_session_initial_utm_term": "String",+ "$initial_search_engine": "String",+ "$initialization_time": "String","$ip": "String",- "$is_identified": "Nullable(String)",+ "$is_identified": "String","$lib": "String",- "$lib_custom_api_host": "String",- "$lib_version": "String",+ "$lib_version": "LowCardinality(String)","$lib_version__minor": "String",- "$os": "String",+ "$mcp_client_name": "String",+ "$mcp_client_user_agent": "String",+ "$mcp_duration_ms": "String",+ "$mcp_error_message": "String",+ "$mcp_exec_tool_call_description": "String",+ "$mcp_exec_tool_call_name": "String",+ "$mcp_intent": "String",+ "$mcp_intent_source": "String",+ "$mcp_is_error": "String",+ "$mcp_listed_tool_names": "Array(String)",+ "$mcp_oauth_client_name": "String",+ "$mcp_organization_id": "String",+ "$mcp_project_id": "String",+ "$mcp_session_id": "String",+ "$mcp_source": "String",+ "$mcp_tool_category": "String",+ "$mcp_tool_description": "String",+ "$mcp_tool_name": "String",+ "$os": "LowCardinality(String)","$os_name": "String",- "$os_version": "String",+ "$os_version": "LowCardinality(String)",+ "$pageview_id": "String","$pathname": "String","$prev_pageview_max_content_percentage": "String","$prev_pageview_max_scroll_percentage": "String","$prev_pageview_pathname": "String",- "$process_person_profile": "Nullable(String)",+ "$process_person_profile": "String",+ "$recording_status": "String","$referrer": "String","$referring_domain": "String",- "$screen_height": "String",+ "$replay_minimum_duration": "String",+ "$replay_sample_rate": "String",+ "$raw_user_agent": "LowCardinality(String)",+ "$search_engine": "String",+ "$screen_height": "LowCardinality(String)","$screen_name": "String",- "$screen_width": "String",- "$sent_at": "String",+ "$screen_width": "LowCardinality(String)","$session_id": "String",+ "$session_entry_host": "String",+ "$session_entry_pathname": "String",+ "$session_entry_referrer": "String",+ "$session_entry_referring_domain": "String",+ "$session_entry_search_engine": "String",+ "$session_entry_url": "String",+ "$session_entry_utm_campaign": "String",+ "$session_entry_utm_content": "String",+ "$session_entry_utm_medium": "String",+ "$session_entry_utm_source": "String",+ "$session_entry_utm_term": "String",+ "$session_recording_event_trigger_activated_session": "String",+ "$session_recording_start_reason": "String",+ "$session_recording_url_trigger_status": "String","$survey_id": "String",+ "$survey_completed": "String",+ "$survey_iteration": "String",+ "$survey_iteration_start_date": "String",+ "$survey_name": "String",+ "$survey_partially_completed": "String","$survey_response": "String","$survey_response_1": "String",+ "$survey_submission_id": "String","$time": "String",+ "$timezone": "LowCardinality(String)",+ "$timezone_offset": "LowCardinality(String)","$user_id": "String",- "$viewport_height": "Nullable(String)",- "$viewport_width": "Nullable(String)",- "$web_vitals_CLS_value": "Nullable(String)",- "$web_vitals_FCP_value": "Nullable(String)",- "$web_vitals_INP_value": "Nullable(String)",- "$web_vitals_LCP_value": "Nullable(String)",+ "$viewport_height": "String",+ "$viewport_width": "String",+ "$web_vitals_CLS_value": "String",+ "$web_vitals_FCP_value": "String",+ "$web_vitals_INP_value": "String",+ "$web_vitals_LCP_value": "String",+ "$web_vitals_enabled_server_side": "LowCardinality(String)","$window_id": "String",+ "action": "String",+ "action_name": "String",+ "address": "String",+ "apiErrorMessage": "String",+ "apiName": "String",+ "app_name": "String",+ "app_version": "String",+ "arguments": "String",+ "audio_duration": "String",+ "authentication_method": "String",+ "auto_chapters": "String",+ "auto_highlights": "String",+ "category": "String",+ "chain": "String",+ "channel": "String",+ "client_id": "String",+ "client_name": "String",+ "commit_sha": "String",+ "community_id": "String",+ "conceptName": "String",+ "content_length": "String",+ "content_safety": "String",+ "context": "String",+ "contributionError": "String",+ "created_at": "String",+ "created_by": "String",+ "created_by_system": "String",+ "currentScreen": "String",+ "current_member_guid": "String",+ "customer_email": "String",+ "deal_id": "String",+ "device_type": "String",+ "disable_institution_search": "String",+ "disfluencies": "String",+ "distinct_id": "String",+ "dual_channel": "String",+ "duration": "String",+ "email": "String",+ "email_domain": "String",+ "_kx": "String",+ "dclid": "String",+ "epik": "String",+ "entity_detection": "String",+ "env": "String",+ "environment": "String",+ "event": "String",+ "event_count_in_month": "String",+ "event_count_in_period": "String",+ "events_projected_amount": "String",+ "fbclid": "String",+ "filter_profanity": "String",+ "filters_count": "String",+ "function": "String",+ "gad_source": "String",+ "gbraid": "String",+ "gclid": "String",+ "gclsrc": "String",+ "gross": "String",+ "group_id": "String",+ "historical_migration": "String",+ "iab_categories": "String",+ "id": "String",+ "index": "String",+ "initial_dclid": "String",+ "initial_fbclid": "String",+ "initial_gclsrc": "String",+ "initial__kx": "String",+ "initial_epik": "String",+ "initial_gad_source": "String",+ "initial_gbraid": "String",+ "initial_gclid": "String",+ "initial_irclid": "String",+ "initial_igshid": "String",+ "initial_li_fat_id": "String",+ "initial_mc_cid": "String",+ "initial_msclkid": "String",+ "initial_qclid": "String",+ "initial_rdt_cid": "String",+ "initial_sccid": "String",+ "initial_utm_campaign": "String",+ "initial_utm_content": "String",+ "initial_utm_medium": "String",+ "initial_utm_source": "String",+ "initial_utm_term": "String",+ "initial_step": "String",+ "initial_ttclid": "String",+ "initial_twclid": "String",+ "initial_wbraid": "String",+ "initiator": "String",+ "insight": "String",+ "institution_name": "String",+ "inviteCode": "String",+ "is_demo_project": "String",+ "is_first_component_load": "String",+ "is_first_event_for_user": "String",+ "is_initial_aggregation": "String",+ "is_oauth": "String",+ "is_organization_first_user": "String",+ "is_test_user": "String",+ "item_count": "String",+ "job_type": "String",+ "key": "String",+ "kind": "String",+ "language_detection": "String",+ "machine_id": "String",+ "message": "String",+ "method": "String",+ "mode": "String",+ "most_recent_app_os": "String",+ "msclkid": "String",+ "mc_cid": "String",+ "igshid": "String",+ "irclid": "String",+ "li_fat_id": "String",+ "qclid": "String",+ "rdt_cid": "String",+ "sccid": "String",+ "ttclid": "String",+ "twclid": "String",+ "name": "String",+ "nativeBuildVersion": "String",+ "numberOfSecrets": "String",+ "orderId": "String",+ "orderType": "String",+ "organization": "String",+ "organization_id": "String",+ "organization_name": "String",+ "organizations": "String",+ "origin": "String",+ "osName": "String",+ "owner_type": "String",+ "page": "String",+ "payment_status": "String",+ "phone": "String",+ "platform": "String",+ "product": "String",+ "product_analytics_projected_amount": "String",+ "product_key": "String",+ "progress": "String",+ "protocol": "String",+ "query": "String",+ "ramp": "String",+ "realm": "String",+ "record-id": "String",+ "recording_count_in_period": "String",+ "recordings_projected_amount": "String",+ "redact_pii": "String",+ "referrer": "String",+ "referrer_id": "String",+ "region": "String",+ "revenue": "String",+ "screen_name": "String",+ "sdk": "String",+ "search_term": "String",+ "sentiment_analysis": "String",+ "session_replay_projected_amount": "String",+ "sku": "String",+ "source": "String",+ "speaker_labels": "String",+ "statusCode": "String",+ "status_message": "String",+ "store_url": "String",+ "stripe_amount_paid": "String",+ "subdomain": "String",+ "subscriptionStatus": "String",+ "summarization": "String",+ "surface_tag": "String",+ "survey_responses_count_in_period": "String",+ "symbol": "String",+ "tag": "String",+ "target": "String",+ "team": "String",+ "testSessionId": "String",+ "thread_id": "String",+ "ticketId": "String",+ "title": "String",+ "token": "String",+ "total_event_actions_count": "String",+ "total_usd": "String",+ "type": "String",+ "url": "String",+ "url_promotion_id": "String",+ "usd": "String",+ "user_agent": "String",+ "user_email_domain": "String",+ "user_platform": "String",+ "utm_campaign": "String",+ "utm_content": "String",+ "utm_medium": "String",+ "utm_source": "String",+ "utm_term": "String",+ "valid_ach_accounts": "String",+ "wbraid": "String",+ "wlo_enabled": "String",+ "workplace_billing_plan": "String",+ "workspace": "String",+ "workspaceId": "String",}-EVENTS_PROPERTIES_JSON_SUBCOLUMNS: dict[str, str] = _nullable_json_subcolumn_types(- EVENTS_PROPERTIES_JSON_SUBCOLUMN_DECLARED_TYPES-)+EVENTS_PROPERTIES_JSON_SUBCOLUMNS = EVENTS_PROPERTIES_JSON_SUBCOLUMN_DECLARED_TYPESPERSON_PROPERTIES_JSON_SUBCOLUMN_DECLARED_TYPES: dict[str, str] = {"$app_version": "String",- "$browser": "String",+ "$app_build": "String",+ "$app_name": "String",+ "$app_namespace": "String",+ "$browser": "LowCardinality(String)",+ "$browser_language": "String",+ "$browser_language_prefix": "String",+ "$browser_type": "String",+ "$browser_version": "LowCardinality(String)","$current_url": "String",- "$geoip_continent_name": "String",- "$geoip_country_code": "String",- "$geoip_country_name": "String",+ "$device": "String",+ "$device_id": "String",+ "$device_manufacturer": "String",+ "$device_model": "String",+ "$device_name": "String",+ "$device_type": "LowCardinality(String)",+ "$geoip_continent_name": "LowCardinality(String)",+ "$geoip_continent_code": "LowCardinality(String)",+ "$geoip_country_code": "LowCardinality(String)",+ "$geoip_country_name": "LowCardinality(String)",+ "$geoip_city_name": "LowCardinality(String)",+ "$geoip_postal_code": "String",+ "$geoip_subdivision_1_code": "String",+ "$geoip_subdivision_1_name": "LowCardinality(String)",+ "$geoip_subdivision_2_code": "String",+ "$geoip_subdivision_2_name": "String",+ "$geoip_time_zone": "LowCardinality(String)","$initial_current_url": "String",+ "$initial_app_build": "String",+ "$initial_app_name": "String",+ "$initial_app_namespace": "String",+ "$initial_app_version": "String",+ "$initial_browser": "LowCardinality(String)",+ "$initial_browser_language": "String",+ "$initial_browser_language_prefix": "String",+ "$initial_browser_type": "String",+ "$initial_browser_version": "LowCardinality(String)",+ "$initial_device": "String",+ "$initial_device_id": "String",+ "$initial_device_manufacturer": "String",+ "$initial_device_model": "String",+ "$initial_device_name": "String",+ "$initial_device_type": "LowCardinality(String)",+ "$initial_geoip_city_name": "String",+ "$initial_geoip_continent_code": "String",+ "$initial_geoip_continent_name": "String",+ "$initial_geoip_country_code": "String",+ "$initial_geoip_country_name": "LowCardinality(String)",+ "$initial_geoip_postal_code": "String",+ "$initial_geoip_subdivision_1_code": "String",+ "$initial_geoip_subdivision_1_name": "LowCardinality(String)",+ "$initial_geoip_subdivision_2_code": "String",+ "$initial_geoip_subdivision_2_name": "String",+ "$initial_geoip_time_zone": "LowCardinality(String)","$initial_fbclid": "String","$initial_gad_source": "String","$initial_gbraid": "String","$initial_gclid": "String",+ "$initial_gclsrc": "String",+ "$initial_dclid": "String","$initial_msclkid": "String",+ "$initial_twclid": "String",+ "$initial_li_fat_id": "String",+ "$initial_mc_cid": "String",+ "$initial_igshid": "String",+ "$initial_ttclid": "String",+ "$initial_rdt_cid": "String",+ "$initial_epik": "String",+ "$initial_qclid": "String",+ "$initial_sccid": "String",+ "$initial_irclid": "String",+ "$initial__kx": "String","$initial_pathname": "String",+ "$initial_os": "LowCardinality(String)",+ "$initial_os_name": "String",+ "$initial_os_version": "LowCardinality(String)",+ "$initial_raw_user_agent": "LowCardinality(String)",+ "$initial_referrer": "String","$initial_referring_domain": "String",+ "$initial_screen_height": "LowCardinality(String)",+ "$initial_screen_width": "LowCardinality(String)",+ "$initial_search_engine": "String","$initial_utm_campaign": "String","$initial_utm_content": "String","$initial_utm_medium": "String","$initial_utm_source": "String","$initial_utm_term": "String",+ "$initial_viewport_height": "String",+ "$initial_viewport_width": "String","$initial_wbraid": "String","$os_name": "String",+ "$os": "LowCardinality(String)",+ "$os_version": "LowCardinality(String)",+ "$pathname": "String",+ "$raw_user_agent": "LowCardinality(String)",+ "$referrer": "String",+ "$screen_height": "LowCardinality(String)",+ "$screen_width": "LowCardinality(String)",+ "$search_engine": "String",+ "$viewport_height": "String",+ "$viewport_width": "String","$referring_domain": "String",+ "$email": "String",+ "$last_seen_survey_date": "String",+ "$organization_id": "String",+ "$product_tour_last_seen_date": "String",+ "$survey_last_seen_date": "String",+ "Email Domain": "String",+ "companyName": "String",+ "customer": "String",+ "email": "String",+ "first_name": "String",+ "hubspot_score": "String",+ "id": "String",+ "icp_role": "String",+ "is_email_verified": "String",+ "is_signed_up": "String",+ "last_name": "String",+ "name": "String",+ "organization_id": "String",+ "organization_member_count": "String",+ "role": "String",+ "role_at_organization": "String",+ "serverMarketing": "String",+ "serverMasterclass": "String",+ "user_email_domain": "String",+ "username": "String",+ "utm_source": "String",+ "utm_medium": "String",+ "utm_campaign": "String",+ "utm_content": "String",+ "utm_term": "String",+ "gclid": "String",+ "gad_source": "String",+ "gclsrc": "String",+ "dclid": "String",+ "gbraid": "String",+ "wbraid": "String",+ "fbclid": "String",+ "msclkid": "String",+ "twclid": "String",+ "li_fat_id": "String",+ "mc_cid": "String",+ "igshid": "String",+ "ttclid": "String",+ "rdt_cid": "String",+ "epik": "String",+ "qclid": "String",+ "sccid": "String",+ "irclid": "String",+ "_kx": "String",+ "val_region": "String",}-PERSON_PROPERTIES_JSON_SUBCOLUMNS: dict[str, str] = _nullable_json_subcolumn_types(- PERSON_PROPERTIES_JSON_SUBCOLUMN_DECLARED_TYPES-)+PERSON_PROPERTIES_JSON_SUBCOLUMNS = PERSON_PROPERTIES_JSON_SUBCOLUMN_DECLARED_TYPESdef EVENTS_JSON_DATA_TABLE_INDEXES() -> str:indexes = [- "INDEX kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3",- "INDEX `minmax_$group_0` properties.`$group_0` TYPE minmax GRANULARITY 1",- "INDEX `minmax_$group_1` properties.`$group_1` TYPE minmax GRANULARITY 1",- "INDEX `minmax_$group_2` properties.`$group_2` TYPE minmax GRANULARITY 1",- "INDEX `minmax_$group_3` properties.`$group_3` TYPE minmax GRANULARITY 1",- "INDEX `minmax_$group_4` properties.`$group_4` TYPE minmax GRANULARITY 1",- "INDEX `minmax_$window_id` properties.`$window_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_$session_id` properties.`$session_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$sent_at` properties.`$sent_at` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$initial_pathname` properties.`$initial_pathname` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$lib_version` properties.`$lib_version` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_utm_campaign` person_properties.`$initial_utm_campaign` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_utm_medium` person_properties.`$initial_utm_medium` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_gclid` person_properties.`$initial_gclid` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_gad_source` person_properties.`$initial_gad_source` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_utm_source` person_properties.`$initial_utm_source` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_referring_domain` person_properties.`$initial_referring_domain` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_utm_term` person_properties.`$initial_utm_term` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_utm_content` person_properties.`$initial_utm_content` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_gbraid` person_properties.`$initial_gbraid` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_wbraid` person_properties.`$initial_wbraid` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_msclkid` person_properties.`$initial_msclkid` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_fbclid` person_properties.`$initial_fbclid` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$geoip_subdivision_1_code` properties.`$geoip_subdivision_1_code` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$prev_pageview_max_scroll_percentage` properties.`$prev_pageview_max_scroll_percentage` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$prev_pageview_max_content_percentage` properties.`$prev_pageview_max_content_percentage` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$prev_pageview_pathname` properties.`$prev_pageview_pathname` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_pathname` person_properties.`$initial_pathname` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$geoip_country_code` person_properties.`$geoip_country_code` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$browser_version` properties.`$browser_version` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$initial_current_url` person_properties.`$initial_current_url` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$current_url` person_properties.`$current_url` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$app_namespace` properties.`$app_namespace` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$os_name` properties.`$os_name` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$os_name` person_properties.`$os_name` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$app_version` person_properties.`$app_version` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$screen_height` properties.`$screen_height` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$screen_width` properties.`$screen_width` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$app_build` properties.`$app_build` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$geoip_country_code` properties.`$geoip_country_code` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$survey_id` properties.`$survey_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$survey_response_1` properties.`$survey_response_1` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$survey_response` properties.`$survey_response` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$el_text` properties.`$el_text` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$os_version` properties.`$os_version` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$feature_flag_payloads` properties.`$feature_flag_payloads` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$groups` properties.`$groups` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$feature_flag` properties.`$feature_flag` TYPE minmax GRANULARITY 1",- "INDEX bf_active_feature_flags properties.`$active_feature_flags` TYPE bloom_filter(0.01) GRANULARITY 1",- "INDEX `minmax_mat_$device_id` properties.`$device_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$geoip_continent_name` person_properties.`$geoip_continent_name` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$feature_flag_response` properties.`$feature_flag_response` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$referring_domain` person_properties.`$referring_domain` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$lib_version__minor` properties.`$lib_version__minor` TYPE minmax GRANULARITY 1",- "INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$lib_custom_api_host` properties.`$lib_custom_api_host` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_pp_$geoip_country_name` person_properties.`$geoip_country_name` TYPE minmax GRANULARITY 1",- "INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$device` properties.`$device` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$exception_issue_id` properties.`$exception_issue_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$exception_fingerprint` properties.`$exception_fingerprint` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$web_vitals_LCP_value` properties.`$web_vitals_LCP_value` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$web_vitals_FCP_value` properties.`$web_vitals_FCP_value` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$web_vitals_CLS_value` properties.`$web_vitals_CLS_value` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$web_vitals_INP_value` properties.`$web_vitals_INP_value` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$viewport_width` properties.`$viewport_width` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$viewport_height` properties.`$viewport_height` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$anon_distinct_id` properties.`$anon_distinct_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$ai_trace_id` properties.`$ai_trace_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$ai_model` properties.`$ai_model` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$ai_provider` properties.`$ai_provider` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$ai_parent_id` properties.`$ai_parent_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$ai_span_id` properties.`$ai_span_id` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$ai_http_status` properties.`$ai_http_status` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$process_person_profile` properties.`$process_person_profile` TYPE minmax GRANULARITY 1",- "INDEX `minmax_mat_$app_version` properties.`$app_version` TYPE minmax GRANULARITY 1",- "INDEX `bloom_mat_$is_identified` properties.`$is_identified` TYPE bloom_filter GRANULARITY 1",- "INDEX `minmax_$session_id_uuid` toUInt128(toUUIDOrNull(properties.`$session_id`)) TYPE minmax GRANULARITY 1",- "INDEX `bloom_filter_$ai_trace_id` properties.`$ai_trace_id` TYPE bloom_filter(0.001) GRANULARITY 2",- "INDEX `bloom_filter_$ai_session_id` properties.`$ai_session_id` TYPE bloom_filter GRANULARITY 1",- "INDEX `minmax_$ai_session_id` properties.`$ai_session_id` TYPE minmax GRANULARITY 1",- "INDEX `set_$ai_is_error` properties.`$ai_is_error` TYPE set(7) GRANULARITY 1",- "INDEX `minmax_mat_$ai_total_cost_usd` properties.`$ai_total_cost_usd` TYPE minmax GRANULARITY 1","INDEX bloom_filter_distinct_id distinct_id TYPE bloom_filter GRANULARITY 1",- "INDEX minmax_sharded_events_timestamp timestamp TYPE minmax GRANULARITY 1",+ "INDEX bloom_filter_uuid uuid TYPE bloom_filter GRANULARITY 1",+ "INDEX bloom_filter_person_id person_id TYPE bloom_filter GRANULARITY 1",+ "INDEX minmax_captured_at captured_at TYPE minmax GRANULARITY 1",+ "INDEX minmax_kafka_timestamp _timestamp TYPE minmax GRANULARITY 1",+ "INDEX minmax_inserted_at inserted_at TYPE minmax GRANULARITY 1",+ "INDEX minmax_timestamp timestamp TYPE minmax GRANULARITY 1","INDEX minmax_historical_migration historical_migration TYPE minmax GRANULARITY 1",- "INDEX `bloom_mat_$feature_flag` properties.`$feature_flag` TYPE bloom_filter GRANULARITY 1",- "INDEX `bloom_filter_$ai_prompt_name` properties.`$ai_prompt_name` TYPE bloom_filter GRANULARITY 1",- "INDEX `minmax_$ai_prompt_name` properties.`$ai_prompt_name` TYPE minmax GRANULARITY 1",- "INDEX `bloom_filter_$ai_experiment_id` properties.`$ai_experiment_id` TYPE bloom_filter GRANULARITY 1",- "INDEX `minmax_$ai_experiment_id` properties.`$ai_experiment_id` TYPE minmax GRANULARITY 1",+ "INDEX minmax_created_at created_at TYPE minmax GRANULARITY 1",]return " , " + "\n , ".join(indexes)diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hclindex a7877ad7569a..f2f1ae9ea7bc 100644--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl@@ -1523,7 +1523,10 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths=32)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -1534,12 +1537,9 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "_timestamp" {type = "DateTime"@@ -1554,27 +1554,22 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group1_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group2_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group3_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group4_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "person_created_at" {type = "DateTime64(3)"@@ -1595,58 +1590,71 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"+ type = "Bool"}- column "$group_0" {+ column "total_event_size" {+ type = "UInt32"+ }+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "elements_chain_href" {type = "String"}+ column "elements_chain_texts" {+ type = "Array(String)"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ }+ column "$group_0" {+ type = "String"+ alias = "ifNull(properties.`$group_0`, '')"+ }column "$group_1" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_1`, '')"}column "$group_2" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_2`, '')"}column "$group_3" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_3`, '')"}column "$group_4" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_4`, '')"}column "$window_id" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$window_id`, '')"}column "$session_id" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$session_id`, '')"}column "$session_id_uuid" {- type = "Nullable(UInt128)"- }- column "elements_chain_href" {- type = "String"- }- column "elements_chain_texts" {- type = "Array(String)"- }- column "elements_chain_ids" {- type = "Array(String)"- }- column "elements_chain_elements" {- type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ type = "Nullable(UInt128)"+ alias = "toUInt128(toUUIDOrNull(properties.`$session_id`))"}engine "distributed" {cluster_name = "posthog"@@ -5514,18 +5522,19 @@ database "posthog" {}table "sharded_events_json" {- primary_key = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)"]- order_by = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)", "distinct_id", "uuid"]- partition_by = "toYYYYMM(timestamp)"+ primary_key = ["team_id", "toDate(timestamp)", "event", "cityHash64(distinct_id)"]+ order_by = ["team_id", "toDate(timestamp)", "event", "cityHash64(distinct_id)", "timestamp", "uuid"]+ partition_by = "clamp(toYYYYMM(timestamp), 202001, 203512)"sample_by = "cityHash64(distinct_id)"settings = {- index_granularity = "8192"- merge_max_block_size = "131072"- merge_max_block_size_bytes = "67108864"- object_serialization_version = "v3"- object_shared_data_serialization_version = "map_with_buckets"- object_shared_data_serialization_version_for_zero_level_parts = "map"- vertical_merge_algorithm_min_rows_to_activate = "0"+ enable_block_number_column = "1"+ enable_block_offset_column = "1"+ index_granularity = "8192"+ map_serialization_version = "with_buckets"+ object_serialization_version = "v3"+ object_shared_data_serialization_version = "map_with_buckets"+ propagate_types_serialization_versions_to_nested_types = "1"+ string_serialization_version = "single_stream"}column "uuid" {type = "UUID"@@ -5534,10 +5543,15 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths=32)"+ ttl = "toDateTime(inserted_at) + toIntervalDay(60)"}column "timestamp" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ codec = "GCD, Default"}column "team_id" {type = "Int64"@@ -5545,18 +5559,18 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ codec = "GCD, Default"}column "_timestamp" {- type = "DateTime"+ type = "DateTime"+ codec = "T64, Default"}column "_offset" {- type = "UInt64"+ type = "UInt64"+ codec = "T64, Default"}column "elements_chain" {type = "String"@@ -5565,30 +5579,26 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group1_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group2_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group3_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group4_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "person_created_at" {- type = "DateTime64(3)"+ type = "DateTime64(3)"+ codec = "GCD, Default"}column "group0_created_at" {type = "DateTime64(3)"@@ -5606,54 +5616,31 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"+ codec = "GCD, Default"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"- }- column "$group_0" {- type = "String"- alias = "ifNull(properties.`$group_0`, '')"- }- column "$group_1" {- type = "String"- alias = "ifNull(properties.`$group_1`, '')"- }- column "$group_2" {- type = "String"- alias = "ifNull(properties.`$group_2`, '')"- }- column "$group_3" {- type = "String"- alias = "ifNull(properties.`$group_3`, '')"- }- column "$group_4" {- type = "String"- alias = "ifNull(properties.`$group_4`, '')"+ type = "Bool"}- column "$window_id" {- type = "String"- alias = "ifNull(properties.`$window_id`, '')"+ column "total_event_size" {+ type = "UInt32"+ codec = "T64, Default"}- column "$session_id" {- type = "String"- alias = "ifNull(properties.`$session_id`, '')"+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ codec = "GCD, Default"}- column "$session_id_uuid" {- type = "Nullable(UInt128)"- alias = "toUInt128(toUUIDOrNull(properties.`$session_id`))"+ column "_partition" {+ type = "UInt64"+ codec = "T64, Default"}column "elements_chain_href" {type = "String"@@ -5671,427 +5658,37 @@ database "posthog" {type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"materialized = "arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\\\.|$|:)'))"}- index "kafka_timestamp_minmax_sharded_events" {- expr = "_timestamp"- type = "minmax"- granularity = 3- }- index "minmax_$group_0" {- expr = "properties.`$group_0`"- type = "minmax"- granularity = 1- }- index "minmax_$group_1" {- expr = "properties.`$group_1`"- type = "minmax"- granularity = 1- }- index "minmax_$group_2" {- expr = "properties.`$group_2`"- type = "minmax"- granularity = 1- }- index "minmax_$group_3" {- expr = "properties.`$group_3`"- type = "minmax"- granularity = 1- }- index "minmax_$group_4" {- expr = "properties.`$group_4`"- type = "minmax"- granularity = 1- }- index "minmax_$window_id" {- expr = "properties.`$window_id`"- type = "minmax"- granularity = 1- }- index "minmax_$session_id" {- expr = "properties.`$session_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$sent_at" {- expr = "properties.`$sent_at`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$initial_pathname" {- expr = "properties.`$initial_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_version" {- expr = "properties.`$lib_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_campaign" {- expr = "person_properties.`$initial_utm_campaign`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_medium" {- expr = "person_properties.`$initial_utm_medium`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_gclid" {- expr = "person_properties.`$initial_gclid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_gad_source" {- expr = "person_properties.`$initial_gad_source`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_source" {- expr = "person_properties.`$initial_utm_source`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_referring_domain" {- expr = "person_properties.`$initial_referring_domain`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_term" {- expr = "person_properties.`$initial_utm_term`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_content" {- expr = "person_properties.`$initial_utm_content`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_gbraid" {- expr = "person_properties.`$initial_gbraid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_wbraid" {- expr = "person_properties.`$initial_wbraid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_msclkid" {- expr = "person_properties.`$initial_msclkid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_fbclid" {- expr = "person_properties.`$initial_fbclid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$geoip_subdivision_1_code" {- expr = "properties.`$geoip_subdivision_1_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_max_scroll_percentage" {- expr = "properties.`$prev_pageview_max_scroll_percentage`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_max_content_percentage" {- expr = "properties.`$prev_pageview_max_content_percentage`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_pathname" {- expr = "properties.`$prev_pageview_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_pathname" {- expr = "person_properties.`$initial_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_country_code" {- expr = "person_properties.`$geoip_country_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$browser_version" {- expr = "properties.`$browser_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_current_url" {- expr = "person_properties.`$initial_current_url`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$current_url" {- expr = "person_properties.`$current_url`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_namespace" {- expr = "properties.`$app_namespace`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$os_name" {- expr = "properties.`$os_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$os_name" {- expr = "person_properties.`$os_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$app_version" {- expr = "person_properties.`$app_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$screen_height" {- expr = "properties.`$screen_height`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$screen_width" {- expr = "properties.`$screen_width`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_build" {- expr = "properties.`$app_build`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$geoip_country_code" {- expr = "properties.`$geoip_country_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_id" {- expr = "properties.`$survey_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_response_1" {- expr = "properties.`$survey_response_1`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_response" {- expr = "properties.`$survey_response`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$el_text" {- expr = "properties.`$el_text`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$os_version" {- expr = "properties.`$os_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag_payloads" {- expr = "properties.`$feature_flag_payloads`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$groups" {- expr = "properties.`$groups`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag" {- expr = "properties.`$feature_flag`"- type = "minmax"- granularity = 1- }- index "bf_active_feature_flags" {- expr = "properties.`$active_feature_flags`"- type = "bloom_filter(0.01)"- granularity = 1- }- index "minmax_mat_$device_id" {- expr = "properties.`$device_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_continent_name" {- expr = "person_properties.`$geoip_continent_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag_response" {- expr = "properties.`$feature_flag_response`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$referring_domain" {- expr = "person_properties.`$referring_domain`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_version__minor" {- expr = "properties.`$lib_version__minor`"- type = "minmax"- granularity = 1- }- index "minmax_inserted_at" {- expr = "coalesce(inserted_at, _timestamp)"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_custom_api_host" {- expr = "properties.`$lib_custom_api_host`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_country_name" {- expr = "person_properties.`$geoip_country_name`"- type = "minmax"- granularity = 1- }- index "is_deleted_idx" {- expr = "is_deleted"- type = "minmax"- granularity = 1- }- index "minmax_mat_$device" {- expr = "properties.`$device`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$exception_issue_id" {- expr = "properties.`$exception_issue_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$exception_fingerprint" {- expr = "properties.`$exception_fingerprint`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_LCP_value" {- expr = "properties.`$web_vitals_LCP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_FCP_value" {- expr = "properties.`$web_vitals_FCP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_CLS_value" {- expr = "properties.`$web_vitals_CLS_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_INP_value" {- expr = "properties.`$web_vitals_INP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$viewport_width" {- expr = "properties.`$viewport_width`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$viewport_height" {- expr = "properties.`$viewport_height`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$anon_distinct_id" {- expr = "properties.`$anon_distinct_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_trace_id" {- expr = "properties.`$ai_trace_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_model" {- expr = "properties.`$ai_model`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_provider" {- expr = "properties.`$ai_provider`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_parent_id" {- expr = "properties.`$ai_parent_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_span_id" {- expr = "properties.`$ai_span_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_http_status" {- expr = "properties.`$ai_http_status`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$process_person_profile" {- expr = "properties.`$process_person_profile`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_version" {- expr = "properties.`$app_version`"- type = "minmax"- granularity = 1- }- index "bloom_mat_$is_identified" {- expr = "properties.`$is_identified`"+ index "bloom_filter_distinct_id" {+ expr = "distinct_id"type = "bloom_filter"granularity = 1}- index "minmax_$session_id_uuid" {- expr = "toUInt128(toUUIDOrNull(properties.`$session_id`))"- type = "minmax"+ index "bloom_filter_uuid" {+ expr = "uuid"+ type = "bloom_filter"granularity = 1}- index "bloom_filter_$ai_trace_id" {- expr = "properties.`$ai_trace_id`"- type = "bloom_filter(0.001)"- granularity = 2- }- index "bloom_filter_$ai_session_id" {- expr = "properties.`$ai_session_id`"+ index "bloom_filter_person_id" {+ expr = "person_id"type = "bloom_filter"granularity = 1}- index "minmax_$ai_session_id" {- expr = "properties.`$ai_session_id`"+ index "minmax_captured_at" {+ expr = "captured_at"type = "minmax"granularity = 1}- index "set_$ai_is_error" {- expr = "properties.`$ai_is_error`"- type = "set(7)"- granularity = 1- }- index "minmax_mat_$ai_total_cost_usd" {- expr = "properties.`$ai_total_cost_usd`"+ index "minmax_kafka_timestamp" {+ expr = "_timestamp"type = "minmax"granularity = 1}- index "bloom_filter_distinct_id" {- expr = "distinct_id"- type = "bloom_filter"+ index "minmax_inserted_at" {+ expr = "inserted_at"+ type = "minmax"granularity = 1}- index "minmax_sharded_events_timestamp" {+ index "minmax_timestamp" {expr = "timestamp"type = "minmax"granularity = 1@@ -6101,28 +5698,8 @@ database "posthog" {type = "minmax"granularity = 1}- index "bloom_mat_$feature_flag" {- expr = "properties.`$feature_flag`"- type = "bloom_filter"- granularity = 1- }- index "bloom_filter_$ai_prompt_name" {- expr = "properties.`$ai_prompt_name`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_prompt_name" {- expr = "properties.`$ai_prompt_name`"- type = "minmax"- granularity = 1- }- index "bloom_filter_$ai_experiment_id" {- expr = "properties.`$ai_experiment_id`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_experiment_id" {- expr = "properties.`$ai_experiment_id`"+ index "minmax_created_at" {+ expr = "created_at"type = "minmax"granularity = 1}@@ -9180,7 +8757,10 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths=32)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -9191,12 +8771,9 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "_timestamp" {type = "DateTime"@@ -9211,27 +8788,22 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group1_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group2_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group3_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group4_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "person_created_at" {type = "DateTime64(3)"@@ -9252,22 +8824,27 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"+ type = "Bool"+ }+ column "total_event_size" {+ type = "UInt32"+ }+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "_partition" {+ type = "UInt64"}engine "distributed" {cluster_name = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hclindex 475fd7537a95..86b038d13add 100644--- a/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl@@ -115,6 +115,9 @@ database "posthog" {column "dmat_string_9" {type = "Nullable(String)"}+ column "captured_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }engine "kafka" {collection = "msk_cluster"topic_list = "clickhouse_events_json"@@ -588,7 +591,10 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths=32)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -599,12 +605,9 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "_timestamp" {type = "DateTime"@@ -619,27 +622,22 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group1_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group2_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group3_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group4_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "person_created_at" {type = "DateTime64(3)"@@ -660,22 +658,27 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"+ type = "Bool"+ }+ column "total_event_size" {+ type = "UInt32"+ }+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "_partition" {+ type = "UInt64"}engine "distributed" {cluster_name = "posthog"@@ -809,45 +812,64 @@ database "posthog" {to_table = "posthog.writable_events_json"query = <<SQLSELECT- uuid,- event,- ifNull(- accurateCastOrNull(properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')- ) AS properties,- timestamp,- team_id,- distinct_id,- elements_chain,- created_at,- person_id,- person_created_at,- ifNull(- accurateCastOrNull(person_properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')- ) AS person_properties,- group0_properties,- group1_properties,- group2_properties,- group3_properties,- group4_properties,- group0_created_at,- group1_created_at,- group2_created_at,- group3_created_at,- group4_created_at,- person_mode,- historical_migration,- _timestamp,- _offset,- arrayMap(- i -> (_headers.value[i]),- arrayFilter(- i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),- arrayEnumerate(_headers.name)- )- ) AS consumer_breadcrumbs-FROM posthog.kafka_events_json_native_json+ *,+ accurateCast(byteSize(*) + byteSize(toUInt32(0)), 'UInt32') AS total_event_size+FROM+ (+ SELECT+ uuid,+ event,+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ JSONCleanPostHogEventProperties(source.properties),+ concat('{"$unparseable_properties":', toJSONString(source.properties), '}')+ ) AS properties,+ JSONCleanPostHogTemporaryProperties(+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ source.properties,+ '{}'+ )+ ) AS temporary_properties,+ now64() AS inserted_at,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ if(+ isValidJSON(source.person_properties)+ AND startsWith(trimLeft(source.person_properties), '{'),+ JSONCleanPostHogPersonProperties(source.person_properties),+ concat('{"$unparseable_properties":', toJSONString(source.person_properties), '}')+ ) AS person_properties,+ person_created_at,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ coalesce(captured_at, created_at) AS captured_at,+ _timestamp,+ _offset,+ _partition,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+ FROM posthog.kafka_events_json_native_json AS source+ )SQLcolumn "uuid" {@@ -857,7 +879,13 @@ SQLtype = "String"}column "properties" {- type = "JSON"+ type = "String"+ }+ column "temporary_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -877,12 +905,12 @@ SQLcolumn "person_id" {type = "UUID"}+ column "person_properties" {+ type = "String"+ }column "person_created_at" {type = "DateTime64(3)"}- column "person_properties" {- type = "JSON"- }column "group0_properties" {type = "String"}@@ -919,15 +947,24 @@ SQLcolumn "historical_migration" {type = "Bool"}+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ }column "_timestamp" {type = "Nullable(DateTime)"}column "_offset" {type = "UInt64"}+ column "_partition" {+ type = "UInt64"+ }column "consumer_breadcrumbs" {type = "Array(String)"}+ column "total_event_size" {+ type = "UInt32"+ }}materialized_view "kafka_logs34_avro_mv" {diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hclindex 641e54e0f3d6..3f2ba1d2b02d 100644--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl@@ -1550,7 +1550,10 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths=32)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -1561,12 +1564,9 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "_timestamp" {type = "DateTime"@@ -1581,27 +1581,22 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group1_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group2_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group3_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group4_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "person_created_at" {type = "DateTime64(3)"@@ -1622,58 +1617,71 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"+ type = "Bool"}- column "$group_0" {+ column "total_event_size" {+ type = "UInt32"+ }+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "elements_chain_href" {type = "String"}+ column "elements_chain_texts" {+ type = "Array(String)"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ }+ column "$group_0" {+ type = "String"+ alias = "ifNull(properties.`$group_0`, '')"+ }column "$group_1" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_1`, '')"}column "$group_2" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_2`, '')"}column "$group_3" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_3`, '')"}column "$group_4" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$group_4`, '')"}column "$window_id" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$window_id`, '')"}column "$session_id" {- type = "String"+ type = "String"+ alias = "ifNull(properties.`$session_id`, '')"}column "$session_id_uuid" {- type = "Nullable(UInt128)"- }- column "elements_chain_href" {- type = "String"- }- column "elements_chain_texts" {- type = "Array(String)"- }- column "elements_chain_ids" {- type = "Array(String)"- }- column "elements_chain_elements" {- type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ type = "Nullable(UInt128)"+ alias = "toUInt128(toUUIDOrNull(properties.`$session_id`))"}engine "distributed" {cluster_name = "posthog"@@ -3141,6 +3149,9 @@ database "posthog" {column "dmat_string_9" {type = "Nullable(String)"}+ column "captured_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }engine "kafka" {collection = "msk_cluster"topic_list = "clickhouse_events_json"@@ -11259,18 +11270,19 @@ SQL}table "sharded_events_json" {- primary_key = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)"]- order_by = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)", "distinct_id", "uuid"]- partition_by = "toYYYYMM(timestamp)"+ primary_key = ["team_id", "toDate(timestamp)", "event", "cityHash64(distinct_id)"]+ order_by = ["team_id", "toDate(timestamp)", "event", "cityHash64(distinct_id)", "timestamp", "uuid"]+ partition_by = "clamp(toYYYYMM(timestamp), 202001, 203512)"sample_by = "cityHash64(distinct_id)"settings = {- index_granularity = "8192"- merge_max_block_size = "131072"- merge_max_block_size_bytes = "67108864"- object_serialization_version = "v3"- object_shared_data_serialization_version = "map_with_buckets"- object_shared_data_serialization_version_for_zero_level_parts = "map"- vertical_merge_algorithm_min_rows_to_activate = "0"+ enable_block_number_column = "1"+ enable_block_offset_column = "1"+ index_granularity = "8192"+ map_serialization_version = "with_buckets"+ object_serialization_version = "v3"+ object_shared_data_serialization_version = "map_with_buckets"+ propagate_types_serialization_versions_to_nested_types = "1"+ string_serialization_version = "single_stream"}column "uuid" {type = "UUID"@@ -11279,10 +11291,15 @@ SQLtype = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths=32)"+ ttl = "toDateTime(inserted_at) + toIntervalDay(60)"}column "timestamp" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ codec = "GCD, Default"}column "team_id" {type = "Int64"@@ -11290,18 +11307,18 @@ SQLcolumn "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ codec = "GCD, Default"}column "_timestamp" {- type = "DateTime"+ type = "DateTime"+ codec = "T64, Default"}column "_offset" {- type = "UInt64"+ type = "UInt64"+ codec = "T64, Default"}column "elements_chain" {type = "String"@@ -11310,30 +11327,26 @@ SQLtype = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group1_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group2_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group3_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group4_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "person_created_at" {- type = "DateTime64(3)"+ type = "DateTime64(3)"+ codec = "GCD, Default"}column "group0_created_at" {type = "DateTime64(3)"@@ -11351,54 +11364,31 @@ SQLtype = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"+ codec = "GCD, Default"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"- }- column "$group_0" {- type = "String"- alias = "ifNull(properties.`$group_0`, '')"- }- column "$group_1" {- type = "String"- alias = "ifNull(properties.`$group_1`, '')"- }- column "$group_2" {- type = "String"- alias = "ifNull(properties.`$group_2`, '')"- }- column "$group_3" {- type = "String"- alias = "ifNull(properties.`$group_3`, '')"- }- column "$group_4" {- type = "String"- alias = "ifNull(properties.`$group_4`, '')"+ type = "Bool"}- column "$window_id" {- type = "String"- alias = "ifNull(properties.`$window_id`, '')"+ column "total_event_size" {+ type = "UInt32"+ codec = "T64, Default"}- column "$session_id" {- type = "String"- alias = "ifNull(properties.`$session_id`, '')"+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ codec = "GCD, Default"}- column "$session_id_uuid" {- type = "Nullable(UInt128)"- alias = "toUInt128(toUUIDOrNull(properties.`$session_id`))"+ column "_partition" {+ type = "UInt64"+ codec = "T64, Default"}column "elements_chain_href" {type = "String"@@ -11416,510 +11406,100 @@ SQLtype = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"materialized = "arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\\\.|$|:)'))"}- index "kafka_timestamp_minmax_sharded_events" {- expr = "_timestamp"- type = "minmax"- granularity = 3- }- index "minmax_$group_0" {- expr = "properties.`$group_0`"- type = "minmax"+ index "bloom_filter_distinct_id" {+ expr = "distinct_id"+ type = "bloom_filter"granularity = 1}- index "minmax_$group_1" {- expr = "properties.`$group_1`"- type = "minmax"+ index "bloom_filter_uuid" {+ expr = "uuid"+ type = "bloom_filter"granularity = 1}- index "minmax_$group_2" {- expr = "properties.`$group_2`"- type = "minmax"+ index "bloom_filter_person_id" {+ expr = "person_id"+ type = "bloom_filter"granularity = 1}- index "minmax_$group_3" {- expr = "properties.`$group_3`"+ index "minmax_captured_at" {+ expr = "captured_at"type = "minmax"granularity = 1}- index "minmax_$group_4" {- expr = "properties.`$group_4`"+ index "minmax_kafka_timestamp" {+ expr = "_timestamp"type = "minmax"granularity = 1}- index "minmax_$window_id" {- expr = "properties.`$window_id`"+ index "minmax_inserted_at" {+ expr = "inserted_at"type = "minmax"granularity = 1}- index "minmax_$session_id" {- expr = "properties.`$session_id`"+ index "minmax_timestamp" {+ expr = "timestamp"type = "minmax"granularity = 1}- index "minmax_mat_$sent_at" {- expr = "properties.`$sent_at`"+ index "minmax_historical_migration" {+ expr = "historical_migration"type = "minmax"granularity = 1}- index "minmax_mat_$initial_pathname" {- expr = "properties.`$initial_pathname`"+ index "minmax_created_at" {+ expr = "created_at"type = "minmax"granularity = 1}- index "minmax_mat_$lib_version" {- expr = "properties.`$lib_version`"- type = "minmax"- granularity = 1+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.events_json"+ replica_name = "{replica}"+ version_column = "_timestamp"}- index "minmax_mat_pp_$initial_utm_campaign" {- expr = "person_properties.`$initial_utm_campaign`"- type = "minmax"- granularity = 1+ }++ table "sharded_events_recent" {+ order_by = ["team_id", "toStartOfHour(inserted_at)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]+ partition_by = "toStartOfDay(inserted_at)"+ ttl = "toDate(inserted_at) + toIntervalDay(9)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"}- index "minmax_mat_pp_$initial_utm_medium" {- expr = "person_properties.`$initial_utm_medium`"- type = "minmax"- granularity = 1+ column "uuid" {+ type = "UUID"}- index "minmax_mat_pp_$initial_gclid" {- expr = "person_properties.`$initial_gclid`"- type = "minmax"- granularity = 1+ column "event" {+ type = "String"}- index "minmax_mat_pp_$initial_gad_source" {- expr = "person_properties.`$initial_gad_source`"- type = "minmax"- granularity = 1+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"}- index "minmax_mat_pp_$initial_utm_source" {- expr = "person_properties.`$initial_utm_source`"- type = "minmax"- granularity = 1+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"}- index "minmax_mat_pp_$initial_referring_domain" {- expr = "person_properties.`$initial_referring_domain`"- type = "minmax"- granularity = 1+ column "team_id" {+ type = "Int64"}- index "minmax_mat_pp_$initial_utm_term" {- expr = "person_properties.`$initial_utm_term`"- type = "minmax"- granularity = 1+ column "distinct_id" {+ type = "String"}- index "minmax_mat_pp_$initial_utm_content" {- expr = "person_properties.`$initial_utm_content`"- type = "minmax"- granularity = 1+ column "elements_chain" {+ type = "String"}- index "minmax_mat_pp_$initial_gbraid" {- expr = "person_properties.`$initial_gbraid`"- type = "minmax"- granularity = 1+ column "created_at" {+ type = "DateTime64(6, 'UTC')"}- index "minmax_mat_pp_$initial_wbraid" {- expr = "person_properties.`$initial_wbraid`"- type = "minmax"- granularity = 1+ column "person_id" {+ type = "UUID"}- index "minmax_mat_pp_$initial_msclkid" {- expr = "person_properties.`$initial_msclkid`"- type = "minmax"- granularity = 1+ column "person_created_at" {+ type = "DateTime64(3)"}- index "minmax_mat_pp_$initial_fbclid" {- expr = "person_properties.`$initial_fbclid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$geoip_subdivision_1_code" {- expr = "properties.`$geoip_subdivision_1_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_max_scroll_percentage" {- expr = "properties.`$prev_pageview_max_scroll_percentage`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_max_content_percentage" {- expr = "properties.`$prev_pageview_max_content_percentage`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_pathname" {- expr = "properties.`$prev_pageview_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_pathname" {- expr = "person_properties.`$initial_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_country_code" {- expr = "person_properties.`$geoip_country_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$browser_version" {- expr = "properties.`$browser_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_current_url" {- expr = "person_properties.`$initial_current_url`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$current_url" {- expr = "person_properties.`$current_url`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_namespace" {- expr = "properties.`$app_namespace`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$os_name" {- expr = "properties.`$os_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$os_name" {- expr = "person_properties.`$os_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$app_version" {- expr = "person_properties.`$app_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$screen_height" {- expr = "properties.`$screen_height`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$screen_width" {- expr = "properties.`$screen_width`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_build" {- expr = "properties.`$app_build`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$geoip_country_code" {- expr = "properties.`$geoip_country_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_id" {- expr = "properties.`$survey_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_response_1" {- expr = "properties.`$survey_response_1`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_response" {- expr = "properties.`$survey_response`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$el_text" {- expr = "properties.`$el_text`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$os_version" {- expr = "properties.`$os_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag_payloads" {- expr = "properties.`$feature_flag_payloads`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$groups" {- expr = "properties.`$groups`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag" {- expr = "properties.`$feature_flag`"- type = "minmax"- granularity = 1- }- index "bf_active_feature_flags" {- expr = "properties.`$active_feature_flags`"- type = "bloom_filter(0.01)"- granularity = 1- }- index "minmax_mat_$device_id" {- expr = "properties.`$device_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_continent_name" {- expr = "person_properties.`$geoip_continent_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag_response" {- expr = "properties.`$feature_flag_response`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$referring_domain" {- expr = "person_properties.`$referring_domain`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_version__minor" {- expr = "properties.`$lib_version__minor`"- type = "minmax"- granularity = 1- }- index "minmax_inserted_at" {- expr = "coalesce(inserted_at, _timestamp)"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_custom_api_host" {- expr = "properties.`$lib_custom_api_host`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_country_name" {- expr = "person_properties.`$geoip_country_name`"- type = "minmax"- granularity = 1- }- index "is_deleted_idx" {- expr = "is_deleted"- type = "minmax"- granularity = 1- }- index "minmax_mat_$device" {- expr = "properties.`$device`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$exception_issue_id" {- expr = "properties.`$exception_issue_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$exception_fingerprint" {- expr = "properties.`$exception_fingerprint`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_LCP_value" {- expr = "properties.`$web_vitals_LCP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_FCP_value" {- expr = "properties.`$web_vitals_FCP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_CLS_value" {- expr = "properties.`$web_vitals_CLS_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_INP_value" {- expr = "properties.`$web_vitals_INP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$viewport_width" {- expr = "properties.`$viewport_width`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$viewport_height" {- expr = "properties.`$viewport_height`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$anon_distinct_id" {- expr = "properties.`$anon_distinct_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_trace_id" {- expr = "properties.`$ai_trace_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_model" {- expr = "properties.`$ai_model`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_provider" {- expr = "properties.`$ai_provider`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_parent_id" {- expr = "properties.`$ai_parent_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_span_id" {- expr = "properties.`$ai_span_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_http_status" {- expr = "properties.`$ai_http_status`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$process_person_profile" {- expr = "properties.`$process_person_profile`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_version" {- expr = "properties.`$app_version`"- type = "minmax"- granularity = 1- }- index "bloom_mat_$is_identified" {- expr = "properties.`$is_identified`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$session_id_uuid" {- expr = "toUInt128(toUUIDOrNull(properties.`$session_id`))"- type = "minmax"- granularity = 1- }- index "bloom_filter_$ai_trace_id" {- expr = "properties.`$ai_trace_id`"- type = "bloom_filter(0.001)"- granularity = 2- }- index "bloom_filter_$ai_session_id" {- expr = "properties.`$ai_session_id`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_session_id" {- expr = "properties.`$ai_session_id`"- type = "minmax"- granularity = 1- }- index "set_$ai_is_error" {- expr = "properties.`$ai_is_error`"- type = "set(7)"- granularity = 1- }- index "minmax_mat_$ai_total_cost_usd" {- expr = "properties.`$ai_total_cost_usd`"- type = "minmax"- granularity = 1- }- index "bloom_filter_distinct_id" {- expr = "distinct_id"- type = "bloom_filter"- granularity = 1- }- index "minmax_sharded_events_timestamp" {- expr = "timestamp"- type = "minmax"- granularity = 1- }- index "minmax_historical_migration" {- expr = "historical_migration"- type = "minmax"- granularity = 1- }- index "bloom_mat_$feature_flag" {- expr = "properties.`$feature_flag`"- type = "bloom_filter"- granularity = 1- }- index "bloom_filter_$ai_prompt_name" {- expr = "properties.`$ai_prompt_name`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_prompt_name" {- expr = "properties.`$ai_prompt_name`"- type = "minmax"- granularity = 1- }- index "bloom_filter_$ai_experiment_id" {- expr = "properties.`$ai_experiment_id`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_experiment_id" {- expr = "properties.`$ai_experiment_id`"- type = "minmax"- granularity = 1- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/{shard}/posthog.events_json"- replica_name = "{replica}"- version_column = "_timestamp"- }- }-- table "sharded_events_recent" {- order_by = ["team_id", "toStartOfHour(inserted_at)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]- partition_by = "toStartOfDay(inserted_at)"- ttl = "toDate(inserted_at) + toIntervalDay(9)"- settings = {- index_granularity = "8192"- ttl_only_drop_parts = "1"- }- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- codec = "ZSTD(3)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- codec = "ZSTD(3)"+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"}column "group0_properties" {type = "String"@@ -17399,7 +16979,10 @@ SQLtype = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths=32)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -17410,12 +16993,9 @@ SQLcolumn "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "_timestamp" {type = "DateTime"@@ -17430,27 +17010,22 @@ SQLtype = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group1_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group2_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group3_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "group4_properties" {- type = "String"- codec = "ZSTD(3)"+ type = "String"}column "person_created_at" {type = "DateTime64(3)"@@ -17471,22 +17046,27 @@ SQLtype = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"+ type = "Bool"+ }+ column "total_event_size" {+ type = "UInt32"+ }+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "_partition" {+ type = "UInt64"}engine "distributed" {cluster_name = "posthog"@@ -20652,45 +20232,64 @@ SQLto_table = "posthog.writable_events_json"query = <<SQLSELECT- uuid,- event,- ifNull(- accurateCastOrNull(properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')- ) AS properties,- timestamp,- team_id,- distinct_id,- elements_chain,- created_at,- person_id,- person_created_at,- ifNull(- accurateCastOrNull(person_properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')- ) AS person_properties,- group0_properties,- group1_properties,- group2_properties,- group3_properties,- group4_properties,- group0_created_at,- group1_created_at,- group2_created_at,- group3_created_at,- group4_created_at,- person_mode,- historical_migration,- _timestamp,- _offset,- arrayMap(- i -> (_headers.value[i]),- arrayFilter(- i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),- arrayEnumerate(_headers.name)- )- ) AS consumer_breadcrumbs-FROM posthog.kafka_events_json_native_json+ *,+ accurateCast(byteSize(*) + byteSize(toUInt32(0)), 'UInt32') AS total_event_size+FROM+ (+ SELECT+ uuid,+ event,+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ JSONCleanPostHogEventProperties(source.properties),+ concat('{"$unparseable_properties":', toJSONString(source.properties), '}')+ ) AS properties,+ JSONCleanPostHogTemporaryProperties(+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ source.properties,+ '{}'+ )+ ) AS temporary_properties,+ now64() AS inserted_at,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ if(+ isValidJSON(source.person_properties)+ AND startsWith(trimLeft(source.person_properties), '{'),+ JSONCleanPostHogPersonProperties(source.person_properties),+ concat('{"$unparseable_properties":', toJSONString(source.person_properties), '}')+ ) AS person_properties,+ person_created_at,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ coalesce(captured_at, created_at) AS captured_at,+ _timestamp,+ _offset,+ _partition,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+ FROM posthog.kafka_events_json_native_json AS source+ )SQLcolumn "uuid" {@@ -20700,7 +20299,13 @@ SQLtype = "String"}column "properties" {- type = "JSON"+ type = "String"+ }+ column "temporary_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -20720,12 +20325,12 @@ SQLcolumn "person_id" {type = "UUID"}+ column "person_properties" {+ type = "String"+ }column "person_created_at" {type = "DateTime64(3)"}- column "person_properties" {- type = "JSON"- }column "group0_properties" {type = "String"}@@ -20762,15 +20367,24 @@ SQLcolumn "historical_migration" {type = "Bool"}+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ }column "_timestamp" {type = "Nullable(DateTime)"}column "_offset" {type = "UInt64"}+ column "_partition" {+ type = "UInt64"+ }column "consumer_breadcrumbs" {type = "Array(String)"}+ column "total_event_size" {+ type = "UInt32"+ }}materialized_view "events_recent_json_mv" {diff --git a/posthog/clickhouse/hcl/roles/coshared/events_json_write/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/events_json_write/tables.hclindex 72dc0e9a3b30..2b7c7850bd6c 100644--- a/posthog/clickhouse/hcl/roles/coshared/events_json_write/tables.hcl+++ b/posthog/clickhouse/hcl/roles/coshared/events_json_write/tables.hcl@@ -7,7 +7,10 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths = 32)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -18,12 +21,9 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "_timestamp" {type = "DateTime"@@ -38,27 +38,22 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {type = "String"- codec = "ZSTD(3)"}column "group1_properties" {type = "String"- codec = "ZSTD(3)"}column "group2_properties" {type = "String"- codec = "ZSTD(3)"}column "group3_properties" {type = "String"- codec = "ZSTD(3)"}column "group4_properties" {type = "String"- codec = "ZSTD(3)"}column "person_created_at" {type = "DateTime64(3)"@@ -79,22 +74,27 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {- type = "Bool"- default = "false"+ type = "Bool"+ }+ column "total_event_size" {+ type = "UInt32"+ }+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "_partition" {+ type = "UInt64"}engine "distributed" {cluster_name = "posthog"diff --git a/posthog/clickhouse/hcl/roles/data/local/tables.hcl b/posthog/clickhouse/hcl/roles/data/local/tables.hclindex ad11c8d4ebf2..b0d638dfe2a4 100644--- a/posthog/clickhouse/hcl/roles/data/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/data/local/tables.hcl@@ -7,7 +7,10 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths = 32)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -18,12 +21,9 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "_timestamp" {type = "DateTime"@@ -38,27 +38,22 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {type = "String"- codec = "ZSTD(3)"}column "group1_properties" {type = "String"- codec = "ZSTD(3)"}column "group2_properties" {type = "String"- codec = "ZSTD(3)"}column "group3_properties" {type = "String"- codec = "ZSTD(3)"}column "group4_properties" {type = "String"- codec = "ZSTD(3)"}column "person_created_at" {type = "DateTime64(3)"@@ -79,58 +74,71 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {type = "Bool"- default = "false"+ }+ column "total_event_size" {+ type = "UInt32"+ }+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "_partition" {+ type = "UInt64"+ }+ column "elements_chain_href" {+ type = "String"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"}column "$group_0" {type = "String"+ alias = "ifNull(properties.`$group_0`, '')"}column "$group_1" {type = "String"+ alias = "ifNull(properties.`$group_1`, '')"}column "$group_2" {type = "String"+ alias = "ifNull(properties.`$group_2`, '')"}column "$group_3" {type = "String"+ alias = "ifNull(properties.`$group_3`, '')"}column "$group_4" {type = "String"+ alias = "ifNull(properties.`$group_4`, '')"}column "$window_id" {type = "String"+ alias = "ifNull(properties.`$window_id`, '')"}column "$session_id" {type = "String"+ alias = "ifNull(properties.`$session_id`, '')"}column "$session_id_uuid" {type = "Nullable(UInt128)"- }- column "elements_chain_href" {- type = "String"- }- column "elements_chain_texts" {- type = "Array(String)"- }- column "elements_chain_ids" {- type = "Array(String)"- }- column "elements_chain_elements" {- type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ alias = "toUInt128(toUUIDOrNull(properties.`$session_id`))"}engine "distributed" {cluster_name = "posthog"@@ -140,18 +148,19 @@ database "posthog" {}}table "sharded_events_json" {- order_by = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)", "distinct_id", "uuid"]- partition_by = "toYYYYMM(timestamp)"- primary_key = ["team_id", "toDate(timestamp)", "event", "timestamp", "cityHash64(distinct_id)"]+ order_by = ["team_id", "toDate(timestamp)", "event", "cityHash64(distinct_id)", "timestamp", "uuid"]+ partition_by = "clamp(toYYYYMM(timestamp), 202001, 203512)"+ primary_key = ["team_id", "toDate(timestamp)", "event", "cityHash64(distinct_id)"]sample_by = "cityHash64(distinct_id)"settings = {index_granularity = "8192"- merge_max_block_size = "131072"- merge_max_block_size_bytes = "67108864"+ enable_block_number_column = "1"+ enable_block_offset_column = "1"+ map_serialization_version = "with_buckets"+ string_serialization_version = "single_stream"+ propagate_types_serialization_versions_to_nested_types = "1"object_serialization_version = "v3"object_shared_data_serialization_version = "map_with_buckets"- object_shared_data_serialization_version_for_zero_level_parts = "map"- vertical_merge_algorithm_min_rows_to_activate = "0"}column "uuid" {type = "UUID"@@ -160,10 +169,15 @@ database "posthog" {type = "String"}column "properties" {- type = "JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)"+ }+ column "temporary_properties" {+ type = "JSON(max_dynamic_paths = 32)"+ ttl = "toDateTime(inserted_at) + toIntervalDay(60)"}column "timestamp" {type = "DateTime64(6, 'UTC')"+ codec = "GCD, Default"}column "team_id" {type = "Int64"@@ -171,18 +185,18 @@ database "posthog" {column "distinct_id" {type = "String"}- column "elements_hash" {- type = "String"- default = "''"- }column "created_at" {- type = "DateTime64(6, 'UTC')"+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ codec = "GCD, Default"}column "_timestamp" {type = "DateTime"+ codec = "T64, Default"}column "_offset" {type = "UInt64"+ codec = "T64, Default"}column "elements_chain" {type = "String"@@ -191,30 +205,26 @@ database "posthog" {type = "UUID"}column "person_properties" {- type = "JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String))"+ type = "JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String)"}column "group0_properties" {type = "String"- codec = "ZSTD(3)"}column "group1_properties" {type = "String"- codec = "ZSTD(3)"}column "group2_properties" {type = "String"- codec = "ZSTD(3)"}column "group3_properties" {type = "String"- codec = "ZSTD(3)"}column "group4_properties" {type = "String"- codec = "ZSTD(3)"}column "person_created_at" {type = "DateTime64(3)"+ codec = "GCD, Default"}column "group0_created_at" {type = "DateTime64(3)"@@ -232,54 +242,31 @@ database "posthog" {type = "DateTime64(3)"}column "inserted_at" {- type = "Nullable(DateTime64(6, 'UTC'))"+ type = "DateTime64(6, 'UTC')"default = "now64()"+ codec = "GCD, Default"}column "person_mode" {type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"}- column "is_deleted" {- type = "Bool"- default = "false"- }column "consumer_breadcrumbs" {type = "Array(String)"}column "historical_migration" {type = "Bool"- default = "false"}- column "$group_0" {- type = "String"- alias = "ifNull(properties.`$group_0`, '')"+ column "total_event_size" {+ type = "UInt32"+ codec = "T64, Default"}- column "$group_1" {- type = "String"- alias = "ifNull(properties.`$group_1`, '')"- }- column "$group_2" {- type = "String"- alias = "ifNull(properties.`$group_2`, '')"- }- column "$group_3" {- type = "String"- alias = "ifNull(properties.`$group_3`, '')"- }- column "$group_4" {- type = "String"- alias = "ifNull(properties.`$group_4`, '')"- }- column "$window_id" {- type = "String"- alias = "ifNull(properties.`$window_id`, '')"- }- column "$session_id" {- type = "String"- alias = "ifNull(properties.`$session_id`, '')"+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ codec = "GCD, Default"}- column "$session_id_uuid" {- type = "Nullable(UInt128)"- alias = "toUInt128(toUUIDOrNull(properties.`$session_id`))"+ column "_partition" {+ type = "UInt64"+ codec = "T64, Default"}column "elements_chain_href" {type = "String"@@ -297,427 +284,37 @@ database "posthog" {type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"materialized = "arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\\\.|$|:)'))"}- index "kafka_timestamp_minmax_sharded_events" {- expr = "_timestamp"- type = "minmax"- granularity = 3- }- index "minmax_$group_0" {- expr = "properties.`$group_0`"- type = "minmax"- granularity = 1- }- index "minmax_$group_1" {- expr = "properties.`$group_1`"- type = "minmax"- granularity = 1- }- index "minmax_$group_2" {- expr = "properties.`$group_2`"- type = "minmax"- granularity = 1- }- index "minmax_$group_3" {- expr = "properties.`$group_3`"- type = "minmax"- granularity = 1- }- index "minmax_$group_4" {- expr = "properties.`$group_4`"- type = "minmax"- granularity = 1- }- index "minmax_$window_id" {- expr = "properties.`$window_id`"- type = "minmax"- granularity = 1- }- index "minmax_$session_id" {- expr = "properties.`$session_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$sent_at" {- expr = "properties.`$sent_at`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$initial_pathname" {- expr = "properties.`$initial_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_version" {- expr = "properties.`$lib_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_campaign" {- expr = "person_properties.`$initial_utm_campaign`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_medium" {- expr = "person_properties.`$initial_utm_medium`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_gclid" {- expr = "person_properties.`$initial_gclid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_gad_source" {- expr = "person_properties.`$initial_gad_source`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_source" {- expr = "person_properties.`$initial_utm_source`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_referring_domain" {- expr = "person_properties.`$initial_referring_domain`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_term" {- expr = "person_properties.`$initial_utm_term`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_utm_content" {- expr = "person_properties.`$initial_utm_content`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_gbraid" {- expr = "person_properties.`$initial_gbraid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_wbraid" {- expr = "person_properties.`$initial_wbraid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_msclkid" {- expr = "person_properties.`$initial_msclkid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_fbclid" {- expr = "person_properties.`$initial_fbclid`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$geoip_subdivision_1_code" {- expr = "properties.`$geoip_subdivision_1_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_max_scroll_percentage" {- expr = "properties.`$prev_pageview_max_scroll_percentage`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_max_content_percentage" {- expr = "properties.`$prev_pageview_max_content_percentage`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$prev_pageview_pathname" {- expr = "properties.`$prev_pageview_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_pathname" {- expr = "person_properties.`$initial_pathname`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_country_code" {- expr = "person_properties.`$geoip_country_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$browser_version" {- expr = "properties.`$browser_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$initial_current_url" {- expr = "person_properties.`$initial_current_url`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$current_url" {- expr = "person_properties.`$current_url`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_namespace" {- expr = "properties.`$app_namespace`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$os_name" {- expr = "properties.`$os_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$os_name" {- expr = "person_properties.`$os_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$app_version" {- expr = "person_properties.`$app_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$screen_height" {- expr = "properties.`$screen_height`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$screen_width" {- expr = "properties.`$screen_width`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_build" {- expr = "properties.`$app_build`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$geoip_country_code" {- expr = "properties.`$geoip_country_code`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_id" {- expr = "properties.`$survey_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_response_1" {- expr = "properties.`$survey_response_1`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$survey_response" {- expr = "properties.`$survey_response`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$el_text" {- expr = "properties.`$el_text`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$os_version" {- expr = "properties.`$os_version`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag_payloads" {- expr = "properties.`$feature_flag_payloads`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$groups" {- expr = "properties.`$groups`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag" {- expr = "properties.`$feature_flag`"- type = "minmax"- granularity = 1- }- index "bf_active_feature_flags" {- expr = "properties.`$active_feature_flags`"- type = "bloom_filter(0.01)"- granularity = 1- }- index "minmax_mat_$device_id" {- expr = "properties.`$device_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_continent_name" {- expr = "person_properties.`$geoip_continent_name`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$feature_flag_response" {- expr = "properties.`$feature_flag_response`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$referring_domain" {- expr = "person_properties.`$referring_domain`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_version__minor" {- expr = "properties.`$lib_version__minor`"- type = "minmax"- granularity = 1- }- index "minmax_inserted_at" {- expr = "coalesce(inserted_at, _timestamp)"- type = "minmax"- granularity = 1- }- index "minmax_mat_$lib_custom_api_host" {- expr = "properties.`$lib_custom_api_host`"- type = "minmax"- granularity = 1- }- index "minmax_mat_pp_$geoip_country_name" {- expr = "person_properties.`$geoip_country_name`"- type = "minmax"- granularity = 1- }- index "is_deleted_idx" {- expr = "is_deleted"- type = "minmax"- granularity = 1- }- index "minmax_mat_$device" {- expr = "properties.`$device`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$exception_issue_id" {- expr = "properties.`$exception_issue_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$exception_fingerprint" {- expr = "properties.`$exception_fingerprint`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_LCP_value" {- expr = "properties.`$web_vitals_LCP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_FCP_value" {- expr = "properties.`$web_vitals_FCP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_CLS_value" {- expr = "properties.`$web_vitals_CLS_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$web_vitals_INP_value" {- expr = "properties.`$web_vitals_INP_value`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$viewport_width" {- expr = "properties.`$viewport_width`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$viewport_height" {- expr = "properties.`$viewport_height`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$anon_distinct_id" {- expr = "properties.`$anon_distinct_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_trace_id" {- expr = "properties.`$ai_trace_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_model" {- expr = "properties.`$ai_model`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_provider" {- expr = "properties.`$ai_provider`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_parent_id" {- expr = "properties.`$ai_parent_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_span_id" {- expr = "properties.`$ai_span_id`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$ai_http_status" {- expr = "properties.`$ai_http_status`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$process_person_profile" {- expr = "properties.`$process_person_profile`"- type = "minmax"- granularity = 1- }- index "minmax_mat_$app_version" {- expr = "properties.`$app_version`"- type = "minmax"- granularity = 1- }- index "bloom_mat_$is_identified" {- expr = "properties.`$is_identified`"+ index "bloom_filter_distinct_id" {+ expr = "distinct_id"type = "bloom_filter"granularity = 1}- index "minmax_$session_id_uuid" {- expr = "toUInt128(toUUIDOrNull(properties.`$session_id`))"- type = "minmax"+ index "bloom_filter_uuid" {+ expr = "uuid"+ type = "bloom_filter"granularity = 1}- index "bloom_filter_$ai_trace_id" {- expr = "properties.`$ai_trace_id`"- type = "bloom_filter(0.001)"- granularity = 2- }- index "bloom_filter_$ai_session_id" {- expr = "properties.`$ai_session_id`"+ index "bloom_filter_person_id" {+ expr = "person_id"type = "bloom_filter"granularity = 1}- index "minmax_$ai_session_id" {- expr = "properties.`$ai_session_id`"+ index "minmax_captured_at" {+ expr = "captured_at"type = "minmax"granularity = 1}- index "set_$ai_is_error" {- expr = "properties.`$ai_is_error`"- type = "set(7)"- granularity = 1- }- index "minmax_mat_$ai_total_cost_usd" {- expr = "properties.`$ai_total_cost_usd`"+ index "minmax_kafka_timestamp" {+ expr = "_timestamp"type = "minmax"granularity = 1}- index "bloom_filter_distinct_id" {- expr = "distinct_id"- type = "bloom_filter"+ index "minmax_inserted_at" {+ expr = "inserted_at"+ type = "minmax"granularity = 1}- index "minmax_sharded_events_timestamp" {+ index "minmax_timestamp" {expr = "timestamp"type = "minmax"granularity = 1@@ -727,28 +324,8 @@ database "posthog" {type = "minmax"granularity = 1}- index "bloom_mat_$feature_flag" {- expr = "properties.`$feature_flag`"- type = "bloom_filter"- granularity = 1- }- index "bloom_filter_$ai_prompt_name" {- expr = "properties.`$ai_prompt_name`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_prompt_name" {- expr = "properties.`$ai_prompt_name`"- type = "minmax"- granularity = 1- }- index "bloom_filter_$ai_experiment_id" {- expr = "properties.`$ai_experiment_id`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_experiment_id" {- expr = "properties.`$ai_experiment_id`"+ index "minmax_created_at" {+ expr = "created_at"type = "minmax"granularity = 1}diff --git a/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl b/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hclindex 687750ba4b99..6557b86198af 100644--- a/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl@@ -115,6 +115,9 @@ database "posthog" {column "dmat_string_9" {type = "Nullable(String)"}+ column "captured_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }engine "kafka" {collection = "msk_cluster"topic_list = "clickhouse_events_json"@@ -126,47 +129,51 @@ database "posthog" {materialized_view "events_json_table_mv" {to_table = "posthog.writable_events_json"- query = <<SQL+ query = <<SQL+SELECT+*,+accurateCast(byteSize(*) + byteSize(toUInt32(0)), 'UInt32') AS total_event_size+FROM+(SELECT- uuid,- event,- ifNull(- accurateCastOrNull(properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')- ) AS properties,- timestamp,- team_id,- distinct_id,- elements_chain,- created_at,- person_id,- person_created_at,- ifNull(- accurateCastOrNull(person_properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')- ) AS person_properties,- group0_properties,- group1_properties,- group2_properties,- group3_properties,- group4_properties,- group0_created_at,- group1_created_at,- group2_created_at,- group3_created_at,- group4_created_at,- person_mode,- historical_migration,- _timestamp,- _offset,- arrayMap(+uuid,+event,+if(isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'), JSONCleanPostHogEventProperties(source.properties), concat('{"$unparseable_properties":', toJSONString(source.properties), '}')) AS properties,+JSONCleanPostHogTemporaryProperties(if(isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'), source.properties, '{}')) AS temporary_properties,+now64() AS inserted_at,+timestamp,+team_id,+distinct_id,+elements_chain,+created_at,+person_id,+if(isValidJSON(source.person_properties) AND startsWith(trimLeft(source.person_properties), '{'), JSONCleanPostHogPersonProperties(source.person_properties), concat('{"$unparseable_properties":', toJSONString(source.person_properties), '}')) AS person_properties,+person_created_at,+group0_properties,+group1_properties,+group2_properties,+group3_properties,+group4_properties,+group0_created_at,+group1_created_at,+group2_created_at,+group3_created_at,+group4_created_at,+person_mode,+historical_migration,+coalesce(captured_at, created_at) AS captured_at,+_timestamp,+_offset,+_partition,+arrayMap(i -> (_headers.value[i]),arrayFilter(- i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),- arrayEnumerate(_headers.name)+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name))- ) AS consumer_breadcrumbs-FROM posthog.kafka_events_json_native_json+) as consumer_breadcrumbs+FROM posthog.kafka_events_json_native_json AS source+)SQLcolumn "uuid" {@@ -176,7 +183,13 @@ SQLtype = "String"}column "properties" {- type = "JSON"+ type = "String"+ }+ column "temporary_properties" {+ type = "String"+ }+ column "inserted_at" {+ type = "DateTime64(3)"}column "timestamp" {type = "DateTime64(6, 'UTC')"@@ -196,12 +209,12 @@ SQLcolumn "person_id" {type = "UUID"}+ column "person_properties" {+ type = "String"+ }column "person_created_at" {type = "DateTime64(3)"}- column "person_properties" {- type = "JSON"- }column "group0_properties" {type = "String"}@@ -238,15 +251,24 @@ SQLcolumn "historical_migration" {type = "Bool"}+ column "captured_at" {+ type = "DateTime64(6, 'UTC')"+ }column "_timestamp" {type = "Nullable(DateTime)"}column "_offset" {type = "UInt64"}+ column "_partition" {+ type = "UInt64"+ }column "consumer_breadcrumbs" {type = "Array(String)"}+ column "total_event_size" {+ type = "UInt32"+ }}diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sqlindex 97978d63bd0d..7561bfd4a68d 100644--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql@@ -1049,137 +1049,49 @@ CREATE TABLE posthog.sharded_events (CREATE TABLE posthog.sharded_events_json (uuid UUID,event String,- properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),- timestamp DateTime64(6, 'UTC'),+ properties JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths=32) TTL toDateTime(inserted_at) + toIntervalDay(60),+ timestamp DateTime64(6, 'UTC') CODEC(GCD, Default),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),- _timestamp DateTime,- _offset UInt64,+ created_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _timestamp DateTime CODEC(T64, Default),+ _offset UInt64 CODEC(T64, Default),elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),- person_created_at DateTime64(3),+ person_properties JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ person_created_at DateTime64(3) CODEC(GCD, Default),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64() CODEC(GCD, Default),person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false,- $group_0 String ALIAS ifNull(properties.`$group_0`, ''),- $group_1 String ALIAS ifNull(properties.`$group_1`, ''),- $group_2 String ALIAS ifNull(properties.`$group_2`, ''),- $group_3 String ALIAS ifNull(properties.`$group_3`, ''),- $group_4 String ALIAS ifNull(properties.`$group_4`, ''),- $window_id String ALIAS ifNull(properties.`$window_id`, ''),- $session_id String ALIAS ifNull(properties.`$session_id`, ''),- $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`)),+ historical_migration Bool,+ total_event_size UInt32 CODEC(T64, Default),+ captured_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _partition UInt64 CODEC(T64, Default),elements_chain_href String MATERIALIZED EXTRACT(elements_chain, '(?::|")href="(.*?)"'),elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")text="(.*?)"')),elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")attr_id="(.*?)"')),elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\.|$|:)')),- INDEX kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3,- INDEX minmax_$group_0 properties.`$group_0` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_1 properties.`$group_1` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_2 properties.`$group_2` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_3 properties.`$group_3` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_4 properties.`$group_4` TYPE minmax GRANULARITY 1,- INDEX minmax_$window_id properties.`$window_id` TYPE minmax GRANULARITY 1,- INDEX minmax_$session_id properties.`$session_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$sent_at properties.`$sent_at` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$initial_pathname properties.`$initial_pathname` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$lib_version properties.`$lib_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_campaign person_properties.`$initial_utm_campaign` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_medium person_properties.`$initial_utm_medium` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_gclid person_properties.`$initial_gclid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_gad_source person_properties.`$initial_gad_source` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_source person_properties.`$initial_utm_source` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_referring_domain person_properties.`$initial_referring_domain` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_term person_properties.`$initial_utm_term` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_content person_properties.`$initial_utm_content` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_gbraid person_properties.`$initial_gbraid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_wbraid person_properties.`$initial_wbraid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_msclkid person_properties.`$initial_msclkid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_fbclid person_properties.`$initial_fbclid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$geoip_subdivision_1_code properties.`$geoip_subdivision_1_code` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$prev_pageview_max_scroll_percentage properties.`$prev_pageview_max_scroll_percentage` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$prev_pageview_max_content_percentage properties.`$prev_pageview_max_content_percentage` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$prev_pageview_pathname properties.`$prev_pageview_pathname` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_pathname person_properties.`$initial_pathname` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$geoip_country_code person_properties.`$geoip_country_code` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$browser_version properties.`$browser_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_current_url person_properties.`$initial_current_url` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$current_url person_properties.`$current_url` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$app_namespace properties.`$app_namespace` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$os_name properties.`$os_name` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$os_name person_properties.`$os_name` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$app_version person_properties.`$app_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$screen_height properties.`$screen_height` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$screen_width properties.`$screen_width` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$app_build properties.`$app_build` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$geoip_country_code properties.`$geoip_country_code` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$survey_id properties.`$survey_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$survey_response_1 properties.`$survey_response_1` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$survey_response properties.`$survey_response` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$el_text properties.`$el_text` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$os_version properties.`$os_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$feature_flag_payloads properties.`$feature_flag_payloads` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$groups properties.`$groups` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$feature_flag properties.`$feature_flag` TYPE minmax GRANULARITY 1,- INDEX bf_active_feature_flags properties.`$active_feature_flags` TYPE bloom_filter(0.01) GRANULARITY 1,- INDEX minmax_mat_$device_id properties.`$device_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$geoip_continent_name person_properties.`$geoip_continent_name` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$feature_flag_response properties.`$feature_flag_response` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$referring_domain person_properties.`$referring_domain` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$lib_version__minor properties.`$lib_version__minor` TYPE minmax GRANULARITY 1,- INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$lib_custom_api_host properties.`$lib_custom_api_host` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$geoip_country_name person_properties.`$geoip_country_name` TYPE minmax GRANULARITY 1,- INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$device properties.`$device` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$exception_issue_id properties.`$exception_issue_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$exception_fingerprint properties.`$exception_fingerprint` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_LCP_value properties.`$web_vitals_LCP_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_FCP_value properties.`$web_vitals_FCP_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_CLS_value properties.`$web_vitals_CLS_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_INP_value properties.`$web_vitals_INP_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$viewport_width properties.`$viewport_width` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$viewport_height properties.`$viewport_height` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$anon_distinct_id properties.`$anon_distinct_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_trace_id properties.`$ai_trace_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_model properties.`$ai_model` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_provider properties.`$ai_provider` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_parent_id properties.`$ai_parent_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_span_id properties.`$ai_span_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_http_status properties.`$ai_http_status` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$process_person_profile properties.`$process_person_profile` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$app_version properties.`$app_version` TYPE minmax GRANULARITY 1,- INDEX bloom_mat_$is_identified properties.`$is_identified` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$session_id_uuid toUInt128(toUUIDOrNull(properties.`$session_id`)) TYPE minmax GRANULARITY 1,- INDEX bloom_filter_$ai_trace_id properties.`$ai_trace_id` TYPE bloom_filter(0.001) GRANULARITY 2,- INDEX bloom_filter_$ai_session_id properties.`$ai_session_id` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$ai_session_id properties.`$ai_session_id` TYPE minmax GRANULARITY 1,- INDEX set_$ai_is_error properties.`$ai_is_error` TYPE set(7) GRANULARITY 1,- INDEX minmax_mat_$ai_total_cost_usd properties.`$ai_total_cost_usd` TYPE minmax GRANULARITY 1,INDEX bloom_filter_distinct_id distinct_id TYPE bloom_filter GRANULARITY 1,- INDEX minmax_sharded_events_timestamp timestamp TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_uuid uuid TYPE bloom_filter GRANULARITY 1,+ INDEX bloom_filter_person_id person_id TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_captured_at captured_at TYPE minmax GRANULARITY 1,+ INDEX minmax_kafka_timestamp _timestamp TYPE minmax GRANULARITY 1,+ INDEX minmax_inserted_at inserted_at TYPE minmax GRANULARITY 1,+ INDEX minmax_timestamp timestamp TYPE minmax GRANULARITY 1,INDEX minmax_historical_migration historical_migration TYPE minmax GRANULARITY 1,- INDEX bloom_mat_$feature_flag properties.`$feature_flag` TYPE bloom_filter GRANULARITY 1,- INDEX bloom_filter_$ai_prompt_name properties.`$ai_prompt_name` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$ai_prompt_name properties.`$ai_prompt_name` TYPE minmax GRANULARITY 1,- INDEX bloom_filter_$ai_experiment_id properties.`$ai_experiment_id` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$ai_experiment_id properties.`$ai_experiment_id` TYPE minmax GRANULARITY 1-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.events_json', '{replica}', _timestamp) PRIMARY KEY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id)) ORDER BY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id), distinct_id, uuid) PARTITION BY toYYYYMM(timestamp) SAMPLE BY cityHash64(distinct_id) SETTINGS index_granularity = 8192, merge_max_block_size = 131072, merge_max_block_size_bytes = 67108864, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', object_shared_data_serialization_version_for_zero_level_parts = 'map', vertical_merge_algorithm_min_rows_to_activate = 0;+ INDEX minmax_created_at created_at TYPE minmax GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.events_json', '{replica}', _timestamp) PRIMARY KEY (team_id, toDate(timestamp), event, cityHash64(distinct_id)) ORDER BY (team_id, toDate(timestamp), event, cityHash64(distinct_id), timestamp, uuid) PARTITION BY clamp(toYYYYMM(timestamp), 202001, 203512) SAMPLE BY cityHash64(distinct_id) SETTINGS enable_block_number_column = 1, enable_block_offset_column = 1, index_granularity = 8192, map_serialization_version = 'with_buckets', object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', propagate_types_serialization_versions_to_nested_types = 1, string_serialization_version = 'single_stream';CREATE TABLE posthog.sharded_events_recent (uuid UUID,event String,@@ -2086,33 +1998,35 @@ CREATE TABLE posthog.writable_events (CREATE TABLE posthog.writable_events_json (uuid UUID,event String,- properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ properties JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths=32),timestamp DateTime64(6, 'UTC'),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),_timestamp DateTime,_offset UInt64,elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),+ person_properties JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,person_created_at DateTime64(3),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(),person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false+ historical_migration Bool,+ total_event_size UInt32,+ captured_at DateTime64(6, 'UTC') DEFAULT now(),+ _partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));CREATE TABLE posthog.writable_events_recent (uuid UUID,@@ -3102,45 +3016,47 @@ CREATE TABLE posthog.events (CREATE TABLE posthog.events_json (uuid UUID,event String,- properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ properties JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths=32),timestamp DateTime64(6, 'UTC'),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),_timestamp DateTime,_offset UInt64,elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),+ person_properties JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,person_created_at DateTime64(3),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(),person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false,- $group_0 String,- $group_1 String,- $group_2 String,- $group_3 String,- $group_4 String,- $window_id String,- $session_id String,- $session_id_uuid Nullable(UInt128),+ historical_migration Bool,+ total_event_size UInt32,+ captured_at DateTime64(6, 'UTC') DEFAULT now(),+ _partition UInt64,elements_chain_href String,elements_chain_texts Array(String),elements_chain_ids Array(String),- elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)),+ $group_0 String ALIAS ifNull(properties.`$group_0`, ''),+ $group_1 String ALIAS ifNull(properties.`$group_1`, ''),+ $group_2 String ALIAS ifNull(properties.`$group_2`, ''),+ $group_3 String ALIAS ifNull(properties.`$group_3`, ''),+ $group_4 String ALIAS ifNull(properties.`$group_4`, ''),+ $window_id String ALIAS ifNull(properties.`$window_id`, ''),+ $session_id String ALIAS ifNull(properties.`$session_id`, ''),+ $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`))) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));CREATE TABLE posthog.events_recent (uuid UUID,diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sqlindex ac8a28dede56..260140a2ce2a 100644--- a/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql@@ -34,7 +34,8 @@ CREATE TABLE posthog.kafka_events_json_native_json (dmat_string_6 Nullable(String),dmat_string_7 Nullable(String),dmat_string_8 Nullable(String),- dmat_string_9 Nullable(String)+ dmat_string_9 Nullable(String),+ captured_at Nullable(DateTime64(6, 'UTC'))) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_events_json_native_json', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_events_json';CREATE TABLE posthog.kafka_logs_avro (uuid String,@@ -164,33 +165,35 @@ CREATE TABLE posthog.query_log_archive (CREATE TABLE posthog.writable_events_json (uuid UUID,event String,- properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ properties JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths=32),timestamp DateTime64(6, 'UTC'),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),_timestamp DateTime,_offset UInt64,elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),+ person_properties JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,person_created_at DateTime64(3),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(),person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false+ historical_migration Bool,+ total_event_size UInt32,+ captured_at DateTime64(6, 'UTC') DEFAULT now(),+ _partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));CREATE TABLE posthog.writable_logs34 (time_bucket DateTime MATERIALIZED toStartOfDay(timestamp),@@ -227,46 +230,65 @@ CREATE TABLE posthog.writable_logs34 (pattern String,pattern_version UInt8) ENGINE = Distributed('logs', 'posthog', 'logs34') SETTINGS background_insert_batch = 1;-CREATE MATERIALIZED VIEW posthog.events_json_table_mv TO posthog.writable_events_json (uuid UUID, event String, properties JSON, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_created_at DateTime64(3), person_properties JSON, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), historical_migration Bool, _timestamp Nullable(DateTime), _offset UInt64, consumer_breadcrumbs Array(String)) AS SELECT- uuid,- event,- ifNull(- accurateCastOrNull(properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')- ) AS properties,- timestamp,- team_id,- distinct_id,- elements_chain,- created_at,- person_id,- person_created_at,- ifNull(- accurateCastOrNull(person_properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')- ) AS person_properties,- group0_properties,- group1_properties,- group2_properties,- group3_properties,- group4_properties,- group0_created_at,- group1_created_at,- group2_created_at,- group3_created_at,- group4_created_at,- person_mode,- historical_migration,- _timestamp,- _offset,- arrayMap(- i -> (_headers.value[i]),- arrayFilter(- i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),- arrayEnumerate(_headers.name)- )- ) AS consumer_breadcrumbs-FROM posthog.kafka_events_json_native_json;+CREATE MATERIALIZED VIEW posthog.events_json_table_mv TO posthog.writable_events_json (uuid UUID, event String, properties String, temporary_properties String, inserted_at DateTime64(3), timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_properties String, person_created_at DateTime64(3), group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), historical_migration Bool, captured_at DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64, consumer_breadcrumbs Array(String), total_event_size UInt32) AS SELECT+ *,+ accurateCast(byteSize(*) + byteSize(toUInt32(0)), 'UInt32') AS total_event_size+FROM+ (+ SELECT+ uuid,+ event,+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ JSONCleanPostHogEventProperties(source.properties),+ concat('{"$unparseable_properties":', toJSONString(source.properties), '}')+ ) AS properties,+ JSONCleanPostHogTemporaryProperties(+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ source.properties,+ '{}'+ )+ ) AS temporary_properties,+ now64() AS inserted_at,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ if(+ isValidJSON(source.person_properties)+ AND startsWith(trimLeft(source.person_properties), '{'),+ JSONCleanPostHogPersonProperties(source.person_properties),+ concat('{"$unparseable_properties":', toJSONString(source.person_properties), '}')+ ) AS person_properties,+ person_created_at,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ coalesce(captured_at, created_at) AS captured_at,+ _timestamp,+ _offset,+ _partition,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+ FROM posthog.kafka_events_json_native_json AS source+ );CREATE MATERIALIZED VIEW posthog.kafka_logs34_avro_mv TO posthog.writable_logs34 (uuid String, trace_id String, span_id String, trace_flags Int32, timestamp DateTime64(6), observed_timestamp DateTime64(6), body String, severity_text String, severity_number Int32, service_name String, instrumentation_scope String, event_name String, attributes_map_str Map(String, String), resource_attributes Map(String, String), team_id Int32, original_expiry_timestamp DateTime64(6), _partition UInt64, _topic LowCardinality(String), _offset UInt64, _record_count Int64, _bytes_uncompressed Nullable(Int64), _bytes_compressed Nullable(Int64), pattern String, pattern_version UInt8) AS SELECTuuid,trace_id,diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sqlindex a9b7305ad905..9a21a17c6ac2 100644--- a/posthog/clickhouse/hcl/sql/local-single/all.sql+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql@@ -463,7 +463,8 @@ CREATE TABLE posthog.kafka_events_json_native_json (dmat_string_6 Nullable(String),dmat_string_7 Nullable(String),dmat_string_8 Nullable(String),- dmat_string_9 Nullable(String)+ dmat_string_9 Nullable(String),+ captured_at Nullable(DateTime64(6, 'UTC'))) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_events_json_native_json', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_events_json';CREATE TABLE posthog.kafka_flag_evaluations (uuid UUID,@@ -2153,137 +2154,49 @@ CREATE TABLE posthog.sharded_events (CREATE TABLE posthog.sharded_events_json (uuid UUID,event String,- properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),- timestamp DateTime64(6, 'UTC'),+ properties JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths=32) TTL toDateTime(inserted_at) + toIntervalDay(60),+ timestamp DateTime64(6, 'UTC') CODEC(GCD, Default),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),- _timestamp DateTime,- _offset UInt64,+ created_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _timestamp DateTime CODEC(T64, Default),+ _offset UInt64 CODEC(T64, Default),elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),- person_created_at DateTime64(3),+ person_properties JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ person_created_at DateTime64(3) CODEC(GCD, Default),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64() CODEC(GCD, Default),person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false,- $group_0 String ALIAS ifNull(properties.`$group_0`, ''),- $group_1 String ALIAS ifNull(properties.`$group_1`, ''),- $group_2 String ALIAS ifNull(properties.`$group_2`, ''),- $group_3 String ALIAS ifNull(properties.`$group_3`, ''),- $group_4 String ALIAS ifNull(properties.`$group_4`, ''),- $window_id String ALIAS ifNull(properties.`$window_id`, ''),- $session_id String ALIAS ifNull(properties.`$session_id`, ''),- $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`)),+ historical_migration Bool,+ total_event_size UInt32 CODEC(T64, Default),+ captured_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _partition UInt64 CODEC(T64, Default),elements_chain_href String MATERIALIZED EXTRACT(elements_chain, '(?::|")href="(.*?)"'),elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")text="(.*?)"')),elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")attr_id="(.*?)"')),elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\.|$|:)')),- INDEX kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3,- INDEX minmax_$group_0 properties.`$group_0` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_1 properties.`$group_1` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_2 properties.`$group_2` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_3 properties.`$group_3` TYPE minmax GRANULARITY 1,- INDEX minmax_$group_4 properties.`$group_4` TYPE minmax GRANULARITY 1,- INDEX minmax_$window_id properties.`$window_id` TYPE minmax GRANULARITY 1,- INDEX minmax_$session_id properties.`$session_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$sent_at properties.`$sent_at` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$initial_pathname properties.`$initial_pathname` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$lib_version properties.`$lib_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_campaign person_properties.`$initial_utm_campaign` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_medium person_properties.`$initial_utm_medium` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_gclid person_properties.`$initial_gclid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_gad_source person_properties.`$initial_gad_source` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_source person_properties.`$initial_utm_source` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_referring_domain person_properties.`$initial_referring_domain` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_term person_properties.`$initial_utm_term` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_utm_content person_properties.`$initial_utm_content` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_gbraid person_properties.`$initial_gbraid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_wbraid person_properties.`$initial_wbraid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_msclkid person_properties.`$initial_msclkid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_fbclid person_properties.`$initial_fbclid` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$geoip_subdivision_1_code properties.`$geoip_subdivision_1_code` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$prev_pageview_max_scroll_percentage properties.`$prev_pageview_max_scroll_percentage` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$prev_pageview_max_content_percentage properties.`$prev_pageview_max_content_percentage` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$prev_pageview_pathname properties.`$prev_pageview_pathname` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_pathname person_properties.`$initial_pathname` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$geoip_country_code person_properties.`$geoip_country_code` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$browser_version properties.`$browser_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$initial_current_url person_properties.`$initial_current_url` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$current_url person_properties.`$current_url` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$app_namespace properties.`$app_namespace` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$os_name properties.`$os_name` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$os_name person_properties.`$os_name` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$app_version person_properties.`$app_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$screen_height properties.`$screen_height` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$screen_width properties.`$screen_width` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$app_build properties.`$app_build` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$geoip_country_code properties.`$geoip_country_code` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$survey_id properties.`$survey_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$survey_response_1 properties.`$survey_response_1` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$survey_response properties.`$survey_response` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$el_text properties.`$el_text` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$os_version properties.`$os_version` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$feature_flag_payloads properties.`$feature_flag_payloads` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$groups properties.`$groups` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$feature_flag properties.`$feature_flag` TYPE minmax GRANULARITY 1,- INDEX bf_active_feature_flags properties.`$active_feature_flags` TYPE bloom_filter(0.01) GRANULARITY 1,- INDEX minmax_mat_$device_id properties.`$device_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$geoip_continent_name person_properties.`$geoip_continent_name` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$feature_flag_response properties.`$feature_flag_response` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$referring_domain person_properties.`$referring_domain` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$lib_version__minor properties.`$lib_version__minor` TYPE minmax GRANULARITY 1,- INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$lib_custom_api_host properties.`$lib_custom_api_host` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_pp_$geoip_country_name person_properties.`$geoip_country_name` TYPE minmax GRANULARITY 1,- INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$device properties.`$device` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$exception_issue_id properties.`$exception_issue_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$exception_fingerprint properties.`$exception_fingerprint` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_LCP_value properties.`$web_vitals_LCP_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_FCP_value properties.`$web_vitals_FCP_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_CLS_value properties.`$web_vitals_CLS_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$web_vitals_INP_value properties.`$web_vitals_INP_value` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$viewport_width properties.`$viewport_width` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$viewport_height properties.`$viewport_height` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$anon_distinct_id properties.`$anon_distinct_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_trace_id properties.`$ai_trace_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_model properties.`$ai_model` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_provider properties.`$ai_provider` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_parent_id properties.`$ai_parent_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_span_id properties.`$ai_span_id` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$ai_http_status properties.`$ai_http_status` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$process_person_profile properties.`$process_person_profile` TYPE minmax GRANULARITY 1,- INDEX minmax_mat_$app_version properties.`$app_version` TYPE minmax GRANULARITY 1,- INDEX bloom_mat_$is_identified properties.`$is_identified` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$session_id_uuid toUInt128(toUUIDOrNull(properties.`$session_id`)) TYPE minmax GRANULARITY 1,- INDEX bloom_filter_$ai_trace_id properties.`$ai_trace_id` TYPE bloom_filter(0.001) GRANULARITY 2,- INDEX bloom_filter_$ai_session_id properties.`$ai_session_id` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$ai_session_id properties.`$ai_session_id` TYPE minmax GRANULARITY 1,- INDEX set_$ai_is_error properties.`$ai_is_error` TYPE set(7) GRANULARITY 1,- INDEX minmax_mat_$ai_total_cost_usd properties.`$ai_total_cost_usd` TYPE minmax GRANULARITY 1,INDEX bloom_filter_distinct_id distinct_id TYPE bloom_filter GRANULARITY 1,- INDEX minmax_sharded_events_timestamp timestamp TYPE minmax GRANULARITY 1,+ INDEX bloom_filter_uuid uuid TYPE bloom_filter GRANULARITY 1,+ INDEX bloom_filter_person_id person_id TYPE bloom_filter GRANULARITY 1,+ INDEX minmax_captured_at captured_at TYPE minmax GRANULARITY 1,+ INDEX minmax_kafka_timestamp _timestamp TYPE minmax GRANULARITY 1,+ INDEX minmax_inserted_at inserted_at TYPE minmax GRANULARITY 1,+ INDEX minmax_timestamp timestamp TYPE minmax GRANULARITY 1,INDEX minmax_historical_migration historical_migration TYPE minmax GRANULARITY 1,- INDEX bloom_mat_$feature_flag properties.`$feature_flag` TYPE bloom_filter GRANULARITY 1,- INDEX bloom_filter_$ai_prompt_name properties.`$ai_prompt_name` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$ai_prompt_name properties.`$ai_prompt_name` TYPE minmax GRANULARITY 1,- INDEX bloom_filter_$ai_experiment_id properties.`$ai_experiment_id` TYPE bloom_filter GRANULARITY 1,- INDEX minmax_$ai_experiment_id properties.`$ai_experiment_id` TYPE minmax GRANULARITY 1-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.events_json', '{replica}', _timestamp) PRIMARY KEY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id)) ORDER BY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id), distinct_id, uuid) PARTITION BY toYYYYMM(timestamp) SAMPLE BY cityHash64(distinct_id) SETTINGS index_granularity = 8192, merge_max_block_size = 131072, merge_max_block_size_bytes = 67108864, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', object_shared_data_serialization_version_for_zero_level_parts = 'map', vertical_merge_algorithm_min_rows_to_activate = 0;+ INDEX minmax_created_at created_at TYPE minmax GRANULARITY 1+) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{shard}/posthog.events_json', '{replica}', _timestamp) PRIMARY KEY (team_id, toDate(timestamp), event, cityHash64(distinct_id)) ORDER BY (team_id, toDate(timestamp), event, cityHash64(distinct_id), timestamp, uuid) PARTITION BY clamp(toYYYYMM(timestamp), 202001, 203512) SAMPLE BY cityHash64(distinct_id) SETTINGS enable_block_number_column = 1, enable_block_offset_column = 1, index_granularity = 8192, map_serialization_version = 'with_buckets', object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', propagate_types_serialization_versions_to_nested_types = 1, string_serialization_version = 'single_stream';CREATE TABLE posthog.sharded_events_recent (uuid UUID,event String,@@ -3898,33 +3811,35 @@ CREATE TABLE posthog.writable_events_dead_letter_queue (CREATE TABLE posthog.writable_events_json (uuid UUID,event String,- properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ properties JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths=32),timestamp DateTime64(6, 'UTC'),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),_timestamp DateTime,_offset UInt64,elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),+ person_properties JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,person_created_at DateTime64(3),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(),person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false+ historical_migration Bool,+ total_event_size UInt32,+ captured_at DateTime64(6, 'UTC') DEFAULT now(),+ _partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));CREATE TABLE posthog.writable_events_recent (uuid UUID,@@ -4756,46 +4671,65 @@ CREATE MATERIALIZED VIEW posthog.events_json_mv TO posthog.writable_events (uuid)) AS consumer_breadcrumbsFROM posthog.kafka_events_json;-CREATE MATERIALIZED VIEW posthog.events_json_table_mv TO posthog.writable_events_json (uuid UUID, event String, properties JSON, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_created_at DateTime64(3), person_properties JSON, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), historical_migration Bool, _timestamp Nullable(DateTime), _offset UInt64, consumer_breadcrumbs Array(String)) AS SELECT- uuid,- event,- ifNull(- accurateCastOrNull(properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')- ) AS properties,- timestamp,- team_id,- distinct_id,- elements_chain,- created_at,- person_id,- person_created_at,- ifNull(- accurateCastOrNull(person_properties, 'JSON'),- CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')- ) AS person_properties,- group0_properties,- group1_properties,- group2_properties,- group3_properties,- group4_properties,- group0_created_at,- group1_created_at,- group2_created_at,- group3_created_at,- group4_created_at,- person_mode,- historical_migration,- _timestamp,- _offset,- arrayMap(- i -> (_headers.value[i]),- arrayFilter(- i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),- arrayEnumerate(_headers.name)- )- ) AS consumer_breadcrumbs-FROM posthog.kafka_events_json_native_json;+CREATE MATERIALIZED VIEW posthog.events_json_table_mv TO posthog.writable_events_json (uuid UUID, event String, properties String, temporary_properties String, inserted_at DateTime64(3), timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_properties String, person_created_at DateTime64(3), group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), historical_migration Bool, captured_at DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64, consumer_breadcrumbs Array(String), total_event_size UInt32) AS SELECT+ *,+ accurateCast(byteSize(*) + byteSize(toUInt32(0)), 'UInt32') AS total_event_size+FROM+ (+ SELECT+ uuid,+ event,+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ JSONCleanPostHogEventProperties(source.properties),+ concat('{"$unparseable_properties":', toJSONString(source.properties), '}')+ ) AS properties,+ JSONCleanPostHogTemporaryProperties(+ if(+ isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'),+ source.properties,+ '{}'+ )+ ) AS temporary_properties,+ now64() AS inserted_at,+ timestamp,+ team_id,+ distinct_id,+ elements_chain,+ created_at,+ person_id,+ if(+ isValidJSON(source.person_properties)+ AND startsWith(trimLeft(source.person_properties), '{'),+ JSONCleanPostHogPersonProperties(source.person_properties),+ concat('{"$unparseable_properties":', toJSONString(source.person_properties), '}')+ ) AS person_properties,+ person_created_at,+ group0_properties,+ group1_properties,+ group2_properties,+ group3_properties,+ group4_properties,+ group0_created_at,+ group1_created_at,+ group2_created_at,+ group3_created_at,+ group4_created_at,+ person_mode,+ historical_migration,+ coalesce(captured_at, created_at) AS captured_at,+ _timestamp,+ _offset,+ _partition,+ arrayMap(+ i -> (_headers.value[i]),+ arrayFilter(+ i -> ((_headers.name[i]) = 'kafka-consumer-breadcrumbs'),+ arrayEnumerate(_headers.name)+ )+ ) AS consumer_breadcrumbs+ FROM posthog.kafka_events_json_native_json AS source+ );CREATE MATERIALIZED VIEW posthog.events_recent_json_mv TO posthog.writable_events_recent (uuid UUID, event String, properties String, timestamp DateTime64(6, 'UTC'), team_id Int64, distinct_id String, elements_chain String, created_at DateTime64(6, 'UTC'), person_id UUID, person_created_at DateTime64(3), person_properties String, group0_properties String, group1_properties String, group2_properties String, group3_properties String, group4_properties String, group0_created_at DateTime64(3), group1_created_at DateTime64(3), group2_created_at DateTime64(3), group3_created_at DateTime64(3), group4_created_at DateTime64(3), person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2), _timestamp DateTime, _offset UInt64) AS SELECTuuid,event,@@ -6649,45 +6583,47 @@ CREATE TABLE posthog.events (CREATE TABLE posthog.events_json (uuid UUID,event String,- properties JSON(max_dynamic_types=8, max_dynamic_paths=256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ properties JSON(max_dynamic_paths=0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_origin` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_session_id` String, `$ai_span_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_tools_called` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths=0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.instance` String, `$groups.organization` String, `$groups.project` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$raw_user_agent` LowCardinality(String), `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$search_engine` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_id` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_completed` String, `$survey_id` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, _kx String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, dclid String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, entity_detection String, env String, environment String, epik String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, igshid String, index String, initial__kx String, initial_dclid String, initial_epik String, initial_fbclid String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_gclsrc String, initial_igshid String, initial_irclid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_step String, initial_ttclid String, initial_twclid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, irclid String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, li_fat_id String, machine_id String, mc_cid String, message String, method String, mode String, most_recent_app_os String, msclkid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, qclid String, query String, ramp String, rdt_cid String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, sccid String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, ttclid String, twclid String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths=32),timestamp DateTime64(6, 'UTC'),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),_timestamp DateTime,_offset UInt64,elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types=6, max_dynamic_paths=32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),+ person_properties JSON(max_dynamic_paths=0, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$email` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial__kx` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_current_url` String, `$initial_dclid` String, `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_epik` String, `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_igshid` String, `$initial_irclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_msclkid` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_pathname` String, `$initial_qclid` String, `$initial_raw_user_agent` LowCardinality(String), `$initial_rdt_cid` String, `$initial_referrer` String, `$initial_referring_domain` String, `$initial_sccid` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_ttclid` String, `$initial_twclid` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$last_seen_survey_date` String, `$organization_id` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pathname` String, `$product_tour_last_seen_date` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$referring_domain` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$survey_last_seen_date` String, `$viewport_height` String, `$viewport_width` String, `Email Domain` String, _kx String, companyName String, customer String, dclid String, email String, epik String, fbclid String, first_name String, gad_source String, gbraid String, gclid String, gclsrc String, hubspot_score String, icp_role String, id String, igshid String, irclid String, is_email_verified String, is_signed_up String, last_name String, li_fat_id String, mc_cid String, msclkid String, name String, organization_id String, organization_member_count String, qclid String, rdt_cid String, role String, role_at_organization String, sccid String, serverMarketing String, serverMasterclass String, ttclid String, twclid String, user_email_domain String, username String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, val_region String, wbraid String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,person_created_at DateTime64(3),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(),person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false,- $group_0 String,- $group_1 String,- $group_2 String,- $group_3 String,- $group_4 String,- $window_id String,- $session_id String,- $session_id_uuid Nullable(UInt128),+ historical_migration Bool,+ total_event_size UInt32,+ captured_at DateTime64(6, 'UTC') DEFAULT now(),+ _partition UInt64,elements_chain_href String,elements_chain_texts Array(String),elements_chain_ids Array(String),- elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)),+ $group_0 String ALIAS ifNull(properties.`$group_0`, ''),+ $group_1 String ALIAS ifNull(properties.`$group_1`, ''),+ $group_2 String ALIAS ifNull(properties.`$group_2`, ''),+ $group_3 String ALIAS ifNull(properties.`$group_3`, ''),+ $group_4 String ALIAS ifNull(properties.`$group_4`, ''),+ $window_id String ALIAS ifNull(properties.`$window_id`, ''),+ $session_id String ALIAS ifNull(properties.`$session_id`, ''),+ $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`))) ENGINE = Distributed('posthog', 'posthog', 'sharded_events_json', sipHash64(distinct_id));CREATE TABLE posthog.events_recent (uuid UUID,diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambrindex b6daa909a57c..a121f4f70548 100644--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr@@ -303,7 +303,7 @@, `dmat_string_8` Nullable(String), `dmat_string_9` Nullable(String)-+ , captured_at Nullable(DateTime64(6, 'UTC'))) ENGINE = Kafka(msk_cluster, kafka_topic_list = 'clickhouse_events_json_test', kafka_group_name = 'clickhouse_events_json_native_json', kafka_format = 'JSONEachRow')@@ -1732,48 +1732,52 @@(uuid UUID,event String,- properties JSON(max_dynamic_types = 8, max_dynamic_paths = 256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ properties JSON(max_dynamic_paths = 0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_session_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_span_id` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_tools_called` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$ai_origin` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_model` String, `$device_manufacturer` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths = 0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$geoip_subdivision_1_code` String, `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.organization` String, `$groups.project` String, `$groups.instance` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$raw_user_agent` LowCardinality(String), `$search_engine` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$session_id` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_id` String, `$survey_completed` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, _kx String, dclid String, epik String, entity_detection String, env String, environment String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, index String, initial_dclid String, initial_fbclid String, initial_gclsrc String, initial__kx String, initial_epik String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_irclid String, initial_igshid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_step String, initial_ttclid String, initial_twclid String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, machine_id String, message String, method String, mode String, most_recent_app_os String, msclkid String, mc_cid String, igshid String, irclid String, li_fat_id String, qclid String, rdt_cid String, sccid String, ttclid String, twclid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, query String, ramp String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths = 32),timestamp DateTime64(6, 'UTC'),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),_timestamp DateTime,_offset UInt64,elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types = 6, max_dynamic_paths = 32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),+ person_properties JSON(max_dynamic_paths = 0, `$app_version` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_city_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial_current_url` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_dclid` String, `$initial_msclkid` String, `$initial_twclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_igshid` String, `$initial_ttclid` String, `$initial_rdt_cid` String, `$initial_epik` String, `$initial_qclid` String, `$initial_sccid` String, `$initial_irclid` String, `$initial__kx` String, `$initial_pathname` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_raw_user_agent` LowCardinality(String), `$initial_referrer` String, `$initial_referring_domain` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$os_name` String, `$os` LowCardinality(String), `$os_version` LowCardinality(String), `$pathname` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$viewport_height` String, `$viewport_width` String, `$referring_domain` String, `$email` String, `$last_seen_survey_date` String, `$organization_id` String, `$product_tour_last_seen_date` String, `$survey_last_seen_date` String, `Email Domain` String, companyName String, customer String, email String, first_name String, hubspot_score String, id String, icp_role String, is_email_verified String, is_signed_up String, last_name String, name String, organization_id String, organization_member_count String, role String, role_at_organization String, serverMarketing String, serverMasterclass String, user_email_domain String, username String, utm_source String, utm_medium String, utm_campaign String, utm_content String, utm_term String, gclid String, gad_source String, gclsrc String, dclid String, gbraid String, wbraid String, fbclid String, msclkid String, twclid String, li_fat_id String, mc_cid String, igshid String, ttclid String, rdt_cid String, epik String, qclid String, sccid String, irclid String, _kx String, val_region String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,person_created_at DateTime64(3),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(),person_mode Enum8('full' = 0, 'propertyless' = 1, 'force_upgrade' = 2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false-- , $group_0 String- , $group_1 String- , $group_2 String- , $group_3 String- , $group_4 String- , $window_id String- , $session_id String- , $session_id_uuid Nullable(UInt128)+ historical_migration Bool,+ total_event_size UInt32,+ captured_at DateTime64(6, 'UTC') DEFAULT now(),+ _partition UInt64+++ , $group_0 String ALIAS ifNull(properties.`$group_0`, '')+ , $group_1 String ALIAS ifNull(properties.`$group_1`, '')+ , $group_2 String ALIAS ifNull(properties.`$group_2`, '')+ , $group_3 String ALIAS ifNull(properties.`$group_3`, '')+ , $group_4 String ALIAS ifNull(properties.`$group_4`, '')+ , $window_id String ALIAS ifNull(properties.`$window_id`, '')+ , $session_id String ALIAS ifNull(properties.`$session_id`, '')+ , $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`))+, elements_chain_href String, elements_chain_texts Array(String), elements_chain_ids Array(String), elements_chain_elements Array(Enum('a', 'button', 'form', 'input', 'select', 'textarea', 'label'))-+) ENGINE = Distributed('posthog', 'posthog_test', 'sharded_events_json', sipHash64(distinct_id))'''@@ -1835,18 +1839,26 @@CREATE MATERIALIZED VIEW IF NOT EXISTS events_json_table_mv ON CLUSTER 'posthog'TO posthog_test.writable_events_json- AS SELECT+ AS+ SELECT+ *,+ accurateCast(byteSize(*) + byteSize(toUInt32(0)), 'UInt32') AS total_event_size+ FROM+ (+ SELECTuuid,event,- ifNull(accurateCastOrNull(properties, 'JSON'), CAST(concat('{"$unparseable_properties":', toJSONString(properties), '}'), 'JSON')) AS properties,+ ifNull(accurateCastOrNull(if(isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'), JSONCleanPostHogEventProperties(source.properties), concat('{"$unparseable_properties":', toJSONString(source.properties), '}')), 'JSON(max_dynamic_paths = 0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_session_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_span_id` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_tools_called` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$ai_origin` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_model` String, `$device_manufacturer` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths = 0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$geoip_subdivision_1_code` String, `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.organization` String, `$groups.project` String, `$groups.instance` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$raw_user_agent` LowCardinality(String), `$search_engine` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$session_id` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_id` String, `$survey_completed` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, _kx String, dclid String, epik String, entity_detection String, env String, environment String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, index String, initial_dclid String, initial_fbclid String, initial_gclsrc String, initial__kx String, initial_epik String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_irclid String, initial_igshid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_step String, initial_ttclid String, initial_twclid String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, machine_id String, message String, method String, mode String, most_recent_app_os String, msclkid String, mc_cid String, igshid String, irclid String, li_fat_id String, qclid String, rdt_cid String, sccid String, ttclid String, twclid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, query String, ramp String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)'), CAST(concat('{"$unparseable_properties":', toJSONString(source.properties), '}'), 'JSON(max_dynamic_paths = 0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_session_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_span_id` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_tools_called` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$ai_origin` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_model` String, `$device_manufacturer` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths = 0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$geoip_subdivision_1_code` String, `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.organization` String, `$groups.project` String, `$groups.instance` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$raw_user_agent` LowCardinality(String), `$search_engine` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$session_id` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_id` String, `$survey_completed` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, _kx String, dclid String, epik String, entity_detection String, env String, environment String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, index String, initial_dclid String, initial_fbclid String, initial_gclsrc String, initial__kx String, initial_epik String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_irclid String, initial_igshid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_step String, initial_ttclid String, initial_twclid String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, machine_id String, message String, method String, mode String, most_recent_app_os String, msclkid String, mc_cid String, igshid String, irclid String, li_fat_id String, qclid String, rdt_cid String, sccid String, ttclid String, twclid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, query String, ramp String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String)')) AS properties,+ JSONCleanPostHogTemporaryProperties(if(isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{'), source.properties, '{}')) AS temporary_properties,+ now64() AS inserted_at,timestamp,team_id,distinct_id,elements_chain,created_at,person_id,+ ifNull(accurateCastOrNull(if(isValidJSON(source.person_properties) AND startsWith(trimLeft(source.person_properties), '{'), JSONCleanPostHogPersonProperties(source.person_properties), concat('{"$unparseable_properties":', toJSONString(source.person_properties), '}')), 'JSON(max_dynamic_paths = 0, `$app_version` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_city_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial_current_url` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_dclid` String, `$initial_msclkid` String, `$initial_twclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_igshid` String, `$initial_ttclid` String, `$initial_rdt_cid` String, `$initial_epik` String, `$initial_qclid` String, `$initial_sccid` String, `$initial_irclid` String, `$initial__kx` String, `$initial_pathname` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_raw_user_agent` LowCardinality(String), `$initial_referrer` String, `$initial_referring_domain` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$os_name` String, `$os` LowCardinality(String), `$os_version` LowCardinality(String), `$pathname` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$viewport_height` String, `$viewport_width` String, `$referring_domain` String, `$email` String, `$last_seen_survey_date` String, `$organization_id` String, `$product_tour_last_seen_date` String, `$survey_last_seen_date` String, `Email Domain` String, companyName String, customer String, email String, first_name String, hubspot_score String, id String, icp_role String, is_email_verified String, is_signed_up String, last_name String, name String, organization_id String, organization_member_count String, role String, role_at_organization String, serverMarketing String, serverMasterclass String, user_email_domain String, username String, utm_source String, utm_medium String, utm_campaign String, utm_content String, utm_term String, gclid String, gad_source String, gclsrc String, dclid String, gbraid String, wbraid String, fbclid String, msclkid String, twclid String, li_fat_id String, mc_cid String, igshid String, ttclid String, rdt_cid String, epik String, qclid String, sccid String, irclid String, _kx String, val_region String)'), CAST(concat('{"$unparseable_properties":', toJSONString(source.person_properties), '}'), 'JSON(max_dynamic_paths = 0, `$app_version` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_city_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial_current_url` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_dclid` String, `$initial_msclkid` String, `$initial_twclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_igshid` String, `$initial_ttclid` String, `$initial_rdt_cid` String, `$initial_epik` String, `$initial_qclid` String, `$initial_sccid` String, `$initial_irclid` String, `$initial__kx` String, `$initial_pathname` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_raw_user_agent` LowCardinality(String), `$initial_referrer` String, `$initial_referring_domain` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$os_name` String, `$os` LowCardinality(String), `$os_version` LowCardinality(String), `$pathname` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$viewport_height` String, `$viewport_width` String, `$referring_domain` String, `$email` String, `$last_seen_survey_date` String, `$organization_id` String, `$product_tour_last_seen_date` String, `$survey_last_seen_date` String, `Email Domain` String, companyName String, customer String, email String, first_name String, hubspot_score String, id String, icp_role String, is_email_verified String, is_signed_up String, last_name String, name String, organization_id String, organization_member_count String, role String, role_at_organization String, serverMarketing String, serverMasterclass String, user_email_domain String, username String, utm_source String, utm_medium String, utm_campaign String, utm_content String, utm_term String, gclid String, gad_source String, gclsrc String, dclid String, gbraid String, wbraid String, fbclid String, msclkid String, twclid String, li_fat_id String, mc_cid String, igshid String, ttclid String, rdt_cid String, epik String, qclid String, sccid String, irclid String, _kx String, val_region String)')) AS person_properties,person_created_at,- ifNull(accurateCastOrNull(person_properties, 'JSON'), CAST(concat('{"$unparseable_properties":', toJSONString(person_properties), '}'), 'JSON')) AS person_properties,group0_properties,group1_properties,group2_properties,@@ -1859,8 +1871,10 @@group4_created_at,person_mode,historical_migration,+ coalesce(captured_at, created_at) AS captured_at,_timestamp,_offset,+ _partition,arrayMap(i -> _headers.value[i],arrayFilter(@@ -1868,7 +1882,8 @@arrayEnumerate(_headers.name))) as consumer_breadcrumbs- FROM posthog_test.kafka_events_json_native_json+ FROM posthog_test.kafka_events_json_native_json AS source+ )'''# ---@@ -2656,7 +2671,7 @@, `dmat_string_8` Nullable(String), `dmat_string_9` Nullable(String)-+ , captured_at Nullable(DateTime64(6, 'UTC'))) ENGINE = Kafka(msk_cluster, kafka_topic_list = 'clickhouse_events_json_test', kafka_group_name = 'clickhouse_events_json_native_json', kafka_format = 'JSONEachRow')@@ -7778,144 +7793,57 @@(uuid UUID,event String,- properties JSON(max_dynamic_types = 8, max_dynamic_paths = 256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),- timestamp DateTime64(6, 'UTC'),+ properties JSON(max_dynamic_paths = 0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_session_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_span_id` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_tools_called` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$ai_origin` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_model` String, `$device_manufacturer` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths = 0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$geoip_subdivision_1_code` String, `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.organization` String, `$groups.project` String, `$groups.instance` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$raw_user_agent` LowCardinality(String), `$search_engine` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$session_id` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_id` String, `$survey_completed` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, _kx String, dclid String, epik String, entity_detection String, env String, environment String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, index String, initial_dclid String, initial_fbclid String, initial_gclsrc String, initial__kx String, initial_epik String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_irclid String, initial_igshid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_step String, initial_ttclid String, initial_twclid String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, machine_id String, message String, method String, mode String, most_recent_app_os String, msclkid String, mc_cid String, igshid String, irclid String, li_fat_id String, qclid String, rdt_cid String, sccid String, ttclid String, twclid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, query String, ramp String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths = 32) TTL toDateTime(inserted_at) + INTERVAL 60 DAY,+ timestamp DateTime64(6, 'UTC') CODEC(GCD, Default),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),- _timestamp DateTime,- _offset UInt64,+ created_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _timestamp DateTime CODEC(T64, Default),+ _offset UInt64 CODEC(T64, Default),elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types = 6, max_dynamic_paths = 32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),- person_created_at DateTime64(3),+ person_properties JSON(max_dynamic_paths = 0, `$app_version` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_city_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial_current_url` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_dclid` String, `$initial_msclkid` String, `$initial_twclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_igshid` String, `$initial_ttclid` String, `$initial_rdt_cid` String, `$initial_epik` String, `$initial_qclid` String, `$initial_sccid` String, `$initial_irclid` String, `$initial__kx` String, `$initial_pathname` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_raw_user_agent` LowCardinality(String), `$initial_referrer` String, `$initial_referring_domain` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$os_name` String, `$os` LowCardinality(String), `$os_version` LowCardinality(String), `$pathname` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$viewport_height` String, `$viewport_width` String, `$referring_domain` String, `$email` String, `$last_seen_survey_date` String, `$organization_id` String, `$product_tour_last_seen_date` String, `$survey_last_seen_date` String, `Email Domain` String, companyName String, customer String, email String, first_name String, hubspot_score String, id String, icp_role String, is_email_verified String, is_signed_up String, last_name String, name String, organization_id String, organization_member_count String, role String, role_at_organization String, serverMarketing String, serverMasterclass String, user_email_domain String, username String, utm_source String, utm_medium String, utm_campaign String, utm_content String, utm_term String, gclid String, gad_source String, gclsrc String, dclid String, gbraid String, wbraid String, fbclid String, msclkid String, twclid String, li_fat_id String, mc_cid String, igshid String, ttclid String, rdt_cid String, epik String, qclid String, sccid String, irclid String, _kx String, val_region String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ person_created_at DateTime64(3) CODEC(GCD, Default),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64() CODEC(GCD, Default),person_mode Enum8('full' = 0, 'propertyless' = 1, 'force_upgrade' = 2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false-- , $group_0 String ALIAS ifNull(properties.`$group_0`, '')- , $group_1 String ALIAS ifNull(properties.`$group_1`, '')- , $group_2 String ALIAS ifNull(properties.`$group_2`, '')- , $group_3 String ALIAS ifNull(properties.`$group_3`, '')- , $group_4 String ALIAS ifNull(properties.`$group_4`, '')- , $window_id String ALIAS ifNull(properties.`$window_id`, '')- , $session_id String ALIAS ifNull(properties.`$session_id`, '')- , $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`))+ historical_migration Bool,+ total_event_size UInt32 CODEC(T64, Default),+ captured_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _partition UInt64 CODEC(T64, Default)+, elements_chain_href String MATERIALIZED extract(elements_chain, '(?::|")href="(.*?)"'), elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")text="(.*?)"')), elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")attr_id="(.*?)"')), elements_chain_elements Array(Enum('a', 'button', 'form', 'input', 'select', 'textarea', 'label')) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\.|$|:)'))- , INDEX kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3- , INDEX `minmax_$group_0` properties.`$group_0` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_1` properties.`$group_1` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_2` properties.`$group_2` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_3` properties.`$group_3` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_4` properties.`$group_4` TYPE minmax GRANULARITY 1- , INDEX `minmax_$window_id` properties.`$window_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_$session_id` properties.`$session_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$sent_at` properties.`$sent_at` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$initial_pathname` properties.`$initial_pathname` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$lib_version` properties.`$lib_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_campaign` person_properties.`$initial_utm_campaign` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_medium` person_properties.`$initial_utm_medium` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_gclid` person_properties.`$initial_gclid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_gad_source` person_properties.`$initial_gad_source` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_source` person_properties.`$initial_utm_source` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_referring_domain` person_properties.`$initial_referring_domain` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_term` person_properties.`$initial_utm_term` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_content` person_properties.`$initial_utm_content` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_gbraid` person_properties.`$initial_gbraid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_wbraid` person_properties.`$initial_wbraid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_msclkid` person_properties.`$initial_msclkid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_fbclid` person_properties.`$initial_fbclid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$geoip_subdivision_1_code` properties.`$geoip_subdivision_1_code` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$prev_pageview_max_scroll_percentage` properties.`$prev_pageview_max_scroll_percentage` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$prev_pageview_max_content_percentage` properties.`$prev_pageview_max_content_percentage` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$prev_pageview_pathname` properties.`$prev_pageview_pathname` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_pathname` person_properties.`$initial_pathname` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$geoip_country_code` person_properties.`$geoip_country_code` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$browser_version` properties.`$browser_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_current_url` person_properties.`$initial_current_url` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$current_url` person_properties.`$current_url` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$app_namespace` properties.`$app_namespace` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$os_name` properties.`$os_name` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$os_name` person_properties.`$os_name` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$app_version` person_properties.`$app_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$screen_height` properties.`$screen_height` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$screen_width` properties.`$screen_width` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$app_build` properties.`$app_build` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$geoip_country_code` properties.`$geoip_country_code` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$survey_id` properties.`$survey_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$survey_response_1` properties.`$survey_response_1` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$survey_response` properties.`$survey_response` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$el_text` properties.`$el_text` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$os_version` properties.`$os_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$feature_flag_payloads` properties.`$feature_flag_payloads` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$groups` properties.`$groups` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$feature_flag` properties.`$feature_flag` TYPE minmax GRANULARITY 1- , INDEX bf_active_feature_flags properties.`$active_feature_flags` TYPE bloom_filter(0.01) GRANULARITY 1- , INDEX `minmax_mat_$device_id` properties.`$device_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$geoip_continent_name` person_properties.`$geoip_continent_name` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$feature_flag_response` properties.`$feature_flag_response` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$referring_domain` person_properties.`$referring_domain` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$lib_version__minor` properties.`$lib_version__minor` TYPE minmax GRANULARITY 1- , INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$lib_custom_api_host` properties.`$lib_custom_api_host` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$geoip_country_name` person_properties.`$geoip_country_name` TYPE minmax GRANULARITY 1- , INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$device` properties.`$device` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$exception_issue_id` properties.`$exception_issue_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$exception_fingerprint` properties.`$exception_fingerprint` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_LCP_value` properties.`$web_vitals_LCP_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_FCP_value` properties.`$web_vitals_FCP_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_CLS_value` properties.`$web_vitals_CLS_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_INP_value` properties.`$web_vitals_INP_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$viewport_width` properties.`$viewport_width` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$viewport_height` properties.`$viewport_height` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$anon_distinct_id` properties.`$anon_distinct_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_trace_id` properties.`$ai_trace_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_model` properties.`$ai_model` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_provider` properties.`$ai_provider` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_parent_id` properties.`$ai_parent_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_span_id` properties.`$ai_span_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_http_status` properties.`$ai_http_status` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$process_person_profile` properties.`$process_person_profile` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$app_version` properties.`$app_version` TYPE minmax GRANULARITY 1- , INDEX `bloom_mat_$is_identified` properties.`$is_identified` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$session_id_uuid` toUInt128(toUUIDOrNull(properties.`$session_id`)) TYPE minmax GRANULARITY 1- , INDEX `bloom_filter_$ai_trace_id` properties.`$ai_trace_id` TYPE bloom_filter(0.001) GRANULARITY 2- , INDEX `bloom_filter_$ai_session_id` properties.`$ai_session_id` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$ai_session_id` properties.`$ai_session_id` TYPE minmax GRANULARITY 1- , INDEX `set_$ai_is_error` properties.`$ai_is_error` TYPE set(7) GRANULARITY 1- , INDEX `minmax_mat_$ai_total_cost_usd` properties.`$ai_total_cost_usd` TYPE minmax GRANULARITY 1+, INDEX bloom_filter_distinct_id distinct_id TYPE bloom_filter GRANULARITY 1- , INDEX minmax_sharded_events_timestamp timestamp TYPE minmax GRANULARITY 1+ , INDEX bloom_filter_uuid uuid TYPE bloom_filter GRANULARITY 1+ , INDEX bloom_filter_person_id person_id TYPE bloom_filter GRANULARITY 1+ , INDEX minmax_captured_at captured_at TYPE minmax GRANULARITY 1+ , INDEX minmax_kafka_timestamp _timestamp TYPE minmax GRANULARITY 1+ , INDEX minmax_inserted_at inserted_at TYPE minmax GRANULARITY 1+ , INDEX minmax_timestamp timestamp TYPE minmax GRANULARITY 1, INDEX minmax_historical_migration historical_migration TYPE minmax GRANULARITY 1- , INDEX `bloom_mat_$feature_flag` properties.`$feature_flag` TYPE bloom_filter GRANULARITY 1- , INDEX `bloom_filter_$ai_prompt_name` properties.`$ai_prompt_name` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$ai_prompt_name` properties.`$ai_prompt_name` TYPE minmax GRANULARITY 1- , INDEX `bloom_filter_$ai_experiment_id` properties.`$ai_experiment_id` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$ai_experiment_id` properties.`$ai_experiment_id` TYPE minmax GRANULARITY 1+ , INDEX minmax_created_at created_at TYPE minmax GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_{shard}/posthog.events_json', '{replica}', _timestamp)- PARTITION BY toYYYYMM(timestamp)- PRIMARY KEY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id))- ORDER BY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id), distinct_id, uuid)+ PARTITION BY clamp(toYYYYMM(timestamp), 202001, 203512)+ PRIMARY KEY (team_id, toDate(timestamp), event, cityHash64(distinct_id))+ ORDER BY (team_id, toDate(timestamp), event, cityHash64(distinct_id), timestamp, uuid)SAMPLE BY cityHash64(distinct_id)- SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', object_shared_data_serialization_version_for_zero_level_parts = 'map', merge_max_block_size = 131072, merge_max_block_size_bytes = 67108864, vertical_merge_algorithm_min_rows_to_activate = 0+ SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', enable_block_offset_column = 1, enable_block_number_column = 1, map_serialization_version = 'with_buckets', string_serialization_version = 'single_stream', propagate_types_serialization_versions_to_nested_types = 1'''# ---@@ -10375,35 +10303,38 @@(uuid UUID,event String,- properties JSON(max_dynamic_types = 8, max_dynamic_paths = 256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),+ properties JSON(max_dynamic_paths = 0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_session_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_span_id` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_tools_called` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$ai_origin` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_model` String, `$device_manufacturer` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths = 0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$geoip_subdivision_1_code` String, `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.organization` String, `$groups.project` String, `$groups.instance` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$raw_user_agent` LowCardinality(String), `$search_engine` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$session_id` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_id` String, `$survey_completed` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, _kx String, dclid String, epik String, entity_detection String, env String, environment String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, index String, initial_dclid String, initial_fbclid String, initial_gclsrc String, initial__kx String, initial_epik String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_irclid String, initial_igshid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_step String, initial_ttclid String, initial_twclid String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, machine_id String, message String, method String, mode String, most_recent_app_os String, msclkid String, mc_cid String, igshid String, irclid String, li_fat_id String, qclid String, rdt_cid String, sccid String, ttclid String, twclid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, query String, ramp String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths = 32),timestamp DateTime64(6, 'UTC'),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),+ created_at DateTime64(6, 'UTC') DEFAULT now(),_timestamp DateTime,_offset UInt64,elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types = 6, max_dynamic_paths = 32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),+ person_properties JSON(max_dynamic_paths = 0, `$app_version` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_city_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial_current_url` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_dclid` String, `$initial_msclkid` String, `$initial_twclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_igshid` String, `$initial_ttclid` String, `$initial_rdt_cid` String, `$initial_epik` String, `$initial_qclid` String, `$initial_sccid` String, `$initial_irclid` String, `$initial__kx` String, `$initial_pathname` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_raw_user_agent` LowCardinality(String), `$initial_referrer` String, `$initial_referring_domain` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$os_name` String, `$os` LowCardinality(String), `$os_version` LowCardinality(String), `$pathname` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$viewport_height` String, `$viewport_width` String, `$referring_domain` String, `$email` String, `$last_seen_survey_date` String, `$organization_id` String, `$product_tour_last_seen_date` String, `$survey_last_seen_date` String, `Email Domain` String, companyName String, customer String, email String, first_name String, hubspot_score String, id String, icp_role String, is_email_verified String, is_signed_up String, last_name String, name String, organization_id String, organization_member_count String, role String, role_at_organization String, serverMarketing String, serverMasterclass String, user_email_domain String, username String, utm_source String, utm_medium String, utm_campaign String, utm_content String, utm_term String, gclid String, gad_source String, gclsrc String, dclid String, gbraid String, wbraid String, fbclid String, msclkid String, twclid String, li_fat_id String, mc_cid String, igshid String, ttclid String, rdt_cid String, epik String, qclid String, sccid String, irclid String, _kx String, val_region String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,person_created_at DateTime64(3),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(),person_mode Enum8('full' = 0, 'propertyless' = 1, 'force_upgrade' = 2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false--+ historical_migration Bool,+ total_event_size UInt32,+ captured_at DateTime64(6, 'UTC') DEFAULT now(),+ _partition UInt64+++) ENGINE = Distributed('posthog', 'posthog_test', 'sharded_events_json', sipHash64(distinct_id))'''@@ -13436,144 +13367,57 @@(uuid UUID,event String,- properties JSON(max_dynamic_types = 8, max_dynamic_paths = 256, `$active_feature_flags` Array(String), `$ai_experiment_id` Nullable(String), `$ai_http_status` Nullable(String), `$ai_is_error` Nullable(String), `$ai_model` Nullable(String), `$ai_parent_id` Nullable(String), `$ai_prompt_name` Nullable(String), `$ai_provider` Nullable(String), `$ai_session_id` Nullable(String), `$ai_span_id` Nullable(String), `$ai_total_cost_usd` Nullable(String), `$ai_trace_id` Nullable(String), `$anon_distinct_id` Nullable(String), `$app_build` Nullable(String), `$app_namespace` Nullable(String), `$app_version` Nullable(String), `$browser` Nullable(String), `$browser_version` Nullable(String), `$current_url` Nullable(String), `$device` Nullable(String), `$device_id` Nullable(String), `$device_model` Nullable(String), `$device_type` Nullable(String), `$el_text` Nullable(String), `$event_type` Nullable(String), `$exception_fingerprint` Nullable(String), `$exception_functions` Array(String), `$exception_issue_id` Nullable(String), `$exception_sources` Array(String), `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flag` Nullable(String), `$feature_flag_payloads` Nullable(String), `$feature_flag_response` Nullable(String), `$geoip_city_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$geoip_subdivision_1_code` Nullable(String), `$group_0` Nullable(String), `$group_1` Nullable(String), `$group_2` Nullable(String), `$group_3` Nullable(String), `$group_4` Nullable(String), `$groups` Nullable(String), `$host` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referrer` Nullable(String), `$initial_referring_domain` Nullable(String), `$ip` Nullable(String), `$is_identified` Nullable(String), `$lib` Nullable(String), `$lib_custom_api_host` Nullable(String), `$lib_version` Nullable(String), `$lib_version__minor` Nullable(String), `$os` Nullable(String), `$os_name` Nullable(String), `$os_version` Nullable(String), `$pathname` Nullable(String), `$prev_pageview_max_content_percentage` Nullable(String), `$prev_pageview_max_scroll_percentage` Nullable(String), `$prev_pageview_pathname` Nullable(String), `$process_person_profile` Nullable(String), `$referrer` Nullable(String), `$referring_domain` Nullable(String), `$screen_height` Nullable(String), `$screen_name` Nullable(String), `$screen_width` Nullable(String), `$sent_at` Nullable(String), `$session_id` Nullable(String), `$survey_id` Nullable(String), `$survey_response` Nullable(String), `$survey_response_1` Nullable(String), `$time` Nullable(String), `$user_id` Nullable(String), `$viewport_height` Nullable(String), `$viewport_width` Nullable(String), `$web_vitals_CLS_value` Nullable(String), `$web_vitals_FCP_value` Nullable(String), `$web_vitals_INP_value` Nullable(String), `$web_vitals_LCP_value` Nullable(String), `$window_id` Nullable(String)),- timestamp DateTime64(6, 'UTC'),+ properties JSON(max_dynamic_paths = 0, `$agent_application_id` String, `$agent_revision_id` String, `$agent_session_id` String, `$agent_turn` String, `$ai_audio_cost_usd` String, `$ai_audio_input_tokens` String, `$ai_audio_output_tokens` String, `$ai_batch_run_id` String, `$ai_cache_creation_input_tokens` String, `$ai_cache_read_input_tokens` String, `$ai_error` String, `$ai_error_normalized` String, `$ai_error_type` String, `$ai_evaluation_allows_na` String, `$ai_evaluation_applicable` String, `$ai_evaluation_id` String, `$ai_evaluation_name` String, `$ai_evaluation_reasoning` String, `$ai_evaluation_result` String, `$ai_evaluation_result_type` String, `$ai_evaluation_runtime` String, `$ai_evaluation_skipped` String, `$ai_evaluation_start_time` String, `$ai_evaluation_type` String, `$ai_experiment_id` String, `$ai_framework` String, `$ai_generation_id` String, `$ai_http_status` String, `$ai_image_cost_usd` String, `$ai_image_input_tokens` String, `$ai_image_output_tokens` String, `$ai_input_cost_usd` String, `$ai_input_tokens` String, `$ai_is_error` String, `$ai_latency` String, `$ai_model` String, `$ai_output_cost_usd` String, `$ai_output_tokens` String, `$ai_parent_id` String, `$ai_prompt_name` String, `$ai_provider` String, `$ai_reasoning_tokens` String, `$ai_request_cost_usd` String, `$ai_session_id` String, `$ai_span_name` String, `$ai_span_type` String, `$ai_span_id` String, `$ai_sentiment_label` String, `$ai_sentiment_message_count` String, `$ai_sentiment_score` String, `$ai_target_event_id` String, `$ai_text_input_tokens` String, `$ai_text_output_tokens` String, `$ai_time_to_first_token` String, `$ai_total_cost_usd` String, `$ai_total_tokens` String, `$ai_tools_called` String, `$ai_trace_id` String, `$ai_trace_name` String, `$ai_video_cost_usd` String, `$ai_video_input_tokens` String, `$ai_video_output_tokens` String, `$ai_web_search_cost_usd` String, `$ai_web_search_count` String, `$ai_origin` String, `$anon_distinct_id` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$app_version` String, `$autocapture_disabled_server_side` LowCardinality(String), `$browser` LowCardinality(String), `$browser_language` LowCardinality(String), `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$config_defaults` LowCardinality(String), `$configured_session_timeout_ms` String, `$current_url` String, `$dead_clicks_enabled_server_side` LowCardinality(String), `$device` String, `$device_id` String, `$device_model` String, `$device_manufacturer` String, `$device_name` String, `$device_type` LowCardinality(String), `$el_text` String, `$event_type` String, `$exception_capture_enabled_server_side` LowCardinality(String), `$exception_fingerprint` String, `$exception_functions` Array(String), `$exception_handled` String, `$exception_is_synthetic` String, `$exception_issue_id` String, `$exception_level` String, `$exception_list` Array(JSON(max_dynamic_paths = 0, type String, value String)), `$exception_message` String, `$exception_proposed_fingerprint` String, `$exception_sources` Array(String), `$exception_type` String, `$exception_types` Array(String), `$exception_values` Array(String), `$feature_flags` Map(LowCardinality(String), LowCardinality(String)), `$geoip_accuracy_radius` String, `$geoip_city_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_latitude` String, `$geoip_longitude` String, `$geoip_postal_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$geoip_subdivision_1_code` String, `$group_0` String, `$group_1` String, `$group_2` String, `$group_3` String, `$group_4` String, `$groups.organization` String, `$groups.project` String, `$groups.instance` String, `$host` String, `$initial_pathname` String, `$initial_referrer` String, `$initial_referring_domain` String, `$client_session_initial_pathname` String, `$client_session_initial_referring_host` String, `$client_session_initial_utm_campaign` String, `$client_session_initial_utm_content` String, `$client_session_initial_utm_medium` String, `$client_session_initial_utm_source` String, `$client_session_initial_utm_term` String, `$initial_search_engine` String, `$initialization_time` String, `$ip` String, `$is_identified` String, `$lib` String, `$lib_version` LowCardinality(String), `$lib_version__minor` String, `$mcp_client_name` String, `$mcp_client_user_agent` String, `$mcp_duration_ms` String, `$mcp_error_message` String, `$mcp_exec_tool_call_description` String, `$mcp_exec_tool_call_name` String, `$mcp_intent` String, `$mcp_intent_source` String, `$mcp_is_error` String, `$mcp_listed_tool_names` Array(String), `$mcp_oauth_client_name` String, `$mcp_organization_id` String, `$mcp_project_id` String, `$mcp_session_id` String, `$mcp_source` String, `$mcp_tool_category` String, `$mcp_tool_description` String, `$mcp_tool_name` String, `$os` LowCardinality(String), `$os_name` String, `$os_version` LowCardinality(String), `$pageview_id` String, `$pathname` String, `$prev_pageview_max_content_percentage` String, `$prev_pageview_max_scroll_percentage` String, `$prev_pageview_pathname` String, `$process_person_profile` String, `$recording_status` String, `$referrer` String, `$referring_domain` String, `$replay_minimum_duration` String, `$replay_sample_rate` String, `$raw_user_agent` LowCardinality(String), `$search_engine` String, `$screen_height` LowCardinality(String), `$screen_name` String, `$screen_width` LowCardinality(String), `$session_id` String, `$session_entry_host` String, `$session_entry_pathname` String, `$session_entry_referrer` String, `$session_entry_referring_domain` String, `$session_entry_search_engine` String, `$session_entry_url` String, `$session_entry_utm_campaign` String, `$session_entry_utm_content` String, `$session_entry_utm_medium` String, `$session_entry_utm_source` String, `$session_entry_utm_term` String, `$session_recording_event_trigger_activated_session` String, `$session_recording_start_reason` String, `$session_recording_url_trigger_status` String, `$survey_id` String, `$survey_completed` String, `$survey_iteration` String, `$survey_iteration_start_date` String, `$survey_name` String, `$survey_partially_completed` String, `$survey_response` String, `$survey_response_1` String, `$survey_submission_id` String, `$time` String, `$timezone` LowCardinality(String), `$timezone_offset` LowCardinality(String), `$user_id` String, `$viewport_height` String, `$viewport_width` String, `$web_vitals_CLS_value` String, `$web_vitals_FCP_value` String, `$web_vitals_INP_value` String, `$web_vitals_LCP_value` String, `$web_vitals_enabled_server_side` LowCardinality(String), `$window_id` String, action String, action_name String, address String, apiErrorMessage String, apiName String, app_name String, app_version String, arguments String, audio_duration String, authentication_method String, auto_chapters String, auto_highlights String, category String, chain String, channel String, client_id String, client_name String, commit_sha String, community_id String, conceptName String, content_length String, content_safety String, context String, contributionError String, created_at String, created_by String, created_by_system String, currentScreen String, current_member_guid String, customer_email String, deal_id String, device_type String, disable_institution_search String, disfluencies String, distinct_id String, dual_channel String, duration String, email String, email_domain String, _kx String, dclid String, epik String, entity_detection String, env String, environment String, event String, event_count_in_month String, event_count_in_period String, events_projected_amount String, fbclid String, filter_profanity String, filters_count String, function String, gad_source String, gbraid String, gclid String, gclsrc String, gross String, group_id String, historical_migration String, iab_categories String, id String, index String, initial_dclid String, initial_fbclid String, initial_gclsrc String, initial__kx String, initial_epik String, initial_gad_source String, initial_gbraid String, initial_gclid String, initial_irclid String, initial_igshid String, initial_li_fat_id String, initial_mc_cid String, initial_msclkid String, initial_qclid String, initial_rdt_cid String, initial_sccid String, initial_utm_campaign String, initial_utm_content String, initial_utm_medium String, initial_utm_source String, initial_utm_term String, initial_step String, initial_ttclid String, initial_twclid String, initial_wbraid String, initiator String, insight String, institution_name String, inviteCode String, is_demo_project String, is_first_component_load String, is_first_event_for_user String, is_initial_aggregation String, is_oauth String, is_organization_first_user String, is_test_user String, item_count String, job_type String, key String, kind String, language_detection String, machine_id String, message String, method String, mode String, most_recent_app_os String, msclkid String, mc_cid String, igshid String, irclid String, li_fat_id String, qclid String, rdt_cid String, sccid String, ttclid String, twclid String, name String, nativeBuildVersion String, numberOfSecrets String, orderId String, orderType String, organization String, organization_id String, organization_name String, organizations String, origin String, osName String, owner_type String, page String, payment_status String, phone String, platform String, product String, product_analytics_projected_amount String, product_key String, progress String, protocol String, query String, ramp String, realm String, `record-id` String, recording_count_in_period String, recordings_projected_amount String, redact_pii String, referrer String, referrer_id String, region String, revenue String, screen_name String, sdk String, search_term String, sentiment_analysis String, session_replay_projected_amount String, sku String, source String, speaker_labels String, statusCode String, status_message String, store_url String, stripe_amount_paid String, subdomain String, subscriptionStatus String, summarization String, surface_tag String, survey_responses_count_in_period String, symbol String, tag String, target String, team String, testSessionId String, thread_id String, ticketId String, title String, token String, total_event_actions_count String, total_usd String, type String, url String, url_promotion_id String, usd String, user_agent String, user_email_domain String, user_platform String, utm_campaign String, utm_content String, utm_medium String, utm_source String, utm_term String, valid_ach_accounts String, wbraid String, wlo_enabled String, workplace_billing_plan String, workspace String, workspaceId String),+ temporary_properties JSON(max_dynamic_paths = 32) TTL toDateTime(inserted_at) + INTERVAL 60 DAY,+ timestamp DateTime64(6, 'UTC') CODEC(GCD, Default),team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),- _timestamp DateTime,- _offset UInt64,+ created_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _timestamp DateTime CODEC(T64, Default),+ _offset UInt64 CODEC(T64, Default),elements_chain String,person_id UUID,- person_properties JSON(max_dynamic_types = 6, max_dynamic_paths = 32, `$app_version` Nullable(String), `$browser` Nullable(String), `$current_url` Nullable(String), `$geoip_continent_name` Nullable(String), `$geoip_country_code` Nullable(String), `$geoip_country_name` Nullable(String), `$initial_current_url` Nullable(String), `$initial_fbclid` Nullable(String), `$initial_gad_source` Nullable(String), `$initial_gbraid` Nullable(String), `$initial_gclid` Nullable(String), `$initial_msclkid` Nullable(String), `$initial_pathname` Nullable(String), `$initial_referring_domain` Nullable(String), `$initial_utm_campaign` Nullable(String), `$initial_utm_content` Nullable(String), `$initial_utm_medium` Nullable(String), `$initial_utm_source` Nullable(String), `$initial_utm_term` Nullable(String), `$initial_wbraid` Nullable(String), `$os_name` Nullable(String), `$referring_domain` Nullable(String)),- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),- person_created_at DateTime64(3),+ person_properties JSON(max_dynamic_paths = 0, `$app_version` String, `$app_build` String, `$app_name` String, `$app_namespace` String, `$browser` LowCardinality(String), `$browser_language` String, `$browser_language_prefix` String, `$browser_type` String, `$browser_version` LowCardinality(String), `$current_url` String, `$device` String, `$device_id` String, `$device_manufacturer` String, `$device_model` String, `$device_name` String, `$device_type` LowCardinality(String), `$geoip_continent_name` LowCardinality(String), `$geoip_continent_code` LowCardinality(String), `$geoip_country_code` LowCardinality(String), `$geoip_country_name` LowCardinality(String), `$geoip_city_name` LowCardinality(String), `$geoip_postal_code` String, `$geoip_subdivision_1_code` String, `$geoip_subdivision_1_name` LowCardinality(String), `$geoip_subdivision_2_code` String, `$geoip_subdivision_2_name` String, `$geoip_time_zone` LowCardinality(String), `$initial_current_url` String, `$initial_app_build` String, `$initial_app_name` String, `$initial_app_namespace` String, `$initial_app_version` String, `$initial_browser` LowCardinality(String), `$initial_browser_language` String, `$initial_browser_language_prefix` String, `$initial_browser_type` String, `$initial_browser_version` LowCardinality(String), `$initial_device` String, `$initial_device_id` String, `$initial_device_manufacturer` String, `$initial_device_model` String, `$initial_device_name` String, `$initial_device_type` LowCardinality(String), `$initial_geoip_city_name` String, `$initial_geoip_continent_code` String, `$initial_geoip_continent_name` String, `$initial_geoip_country_code` String, `$initial_geoip_country_name` LowCardinality(String), `$initial_geoip_postal_code` String, `$initial_geoip_subdivision_1_code` String, `$initial_geoip_subdivision_1_name` LowCardinality(String), `$initial_geoip_subdivision_2_code` String, `$initial_geoip_subdivision_2_name` String, `$initial_geoip_time_zone` LowCardinality(String), `$initial_fbclid` String, `$initial_gad_source` String, `$initial_gbraid` String, `$initial_gclid` String, `$initial_gclsrc` String, `$initial_dclid` String, `$initial_msclkid` String, `$initial_twclid` String, `$initial_li_fat_id` String, `$initial_mc_cid` String, `$initial_igshid` String, `$initial_ttclid` String, `$initial_rdt_cid` String, `$initial_epik` String, `$initial_qclid` String, `$initial_sccid` String, `$initial_irclid` String, `$initial__kx` String, `$initial_pathname` String, `$initial_os` LowCardinality(String), `$initial_os_name` String, `$initial_os_version` LowCardinality(String), `$initial_raw_user_agent` LowCardinality(String), `$initial_referrer` String, `$initial_referring_domain` String, `$initial_screen_height` LowCardinality(String), `$initial_screen_width` LowCardinality(String), `$initial_search_engine` String, `$initial_utm_campaign` String, `$initial_utm_content` String, `$initial_utm_medium` String, `$initial_utm_source` String, `$initial_utm_term` String, `$initial_viewport_height` String, `$initial_viewport_width` String, `$initial_wbraid` String, `$os_name` String, `$os` LowCardinality(String), `$os_version` LowCardinality(String), `$pathname` String, `$raw_user_agent` LowCardinality(String), `$referrer` String, `$screen_height` LowCardinality(String), `$screen_width` LowCardinality(String), `$search_engine` String, `$viewport_height` String, `$viewport_width` String, `$referring_domain` String, `$email` String, `$last_seen_survey_date` String, `$organization_id` String, `$product_tour_last_seen_date` String, `$survey_last_seen_date` String, `Email Domain` String, companyName String, customer String, email String, first_name String, hubspot_score String, id String, icp_role String, is_email_verified String, is_signed_up String, last_name String, name String, organization_id String, organization_member_count String, role String, role_at_organization String, serverMarketing String, serverMasterclass String, user_email_domain String, username String, utm_source String, utm_medium String, utm_campaign String, utm_content String, utm_term String, gclid String, gad_source String, gclsrc String, dclid String, gbraid String, wbraid String, fbclid String, msclkid String, twclid String, li_fat_id String, mc_cid String, igshid String, ttclid String, rdt_cid String, epik String, qclid String, sccid String, irclid String, _kx String, val_region String),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ person_created_at DateTime64(3) CODEC(GCD, Default),group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64() CODEC(GCD, Default),person_mode Enum8('full' = 0, 'propertyless' = 1, 'force_upgrade' = 2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false-- , $group_0 String ALIAS ifNull(properties.`$group_0`, '')- , $group_1 String ALIAS ifNull(properties.`$group_1`, '')- , $group_2 String ALIAS ifNull(properties.`$group_2`, '')- , $group_3 String ALIAS ifNull(properties.`$group_3`, '')- , $group_4 String ALIAS ifNull(properties.`$group_4`, '')- , $window_id String ALIAS ifNull(properties.`$window_id`, '')- , $session_id String ALIAS ifNull(properties.`$session_id`, '')- , $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull(properties.`$session_id`))+ historical_migration Bool,+ total_event_size UInt32 CODEC(T64, Default),+ captured_at DateTime64(6, 'UTC') DEFAULT now() CODEC(GCD, Default),+ _partition UInt64 CODEC(T64, Default)+, elements_chain_href String MATERIALIZED extract(elements_chain, '(?::|")href="(.*?)"'), elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")text="(.*?)"')), elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|")attr_id="(.*?)"')), elements_chain_elements Array(Enum('a', 'button', 'form', 'input', 'select', 'textarea', 'label')) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\.|$|:)'))- , INDEX kafka_timestamp_minmax_sharded_events _timestamp TYPE minmax GRANULARITY 3- , INDEX `minmax_$group_0` properties.`$group_0` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_1` properties.`$group_1` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_2` properties.`$group_2` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_3` properties.`$group_3` TYPE minmax GRANULARITY 1- , INDEX `minmax_$group_4` properties.`$group_4` TYPE minmax GRANULARITY 1- , INDEX `minmax_$window_id` properties.`$window_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_$session_id` properties.`$session_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$sent_at` properties.`$sent_at` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$initial_pathname` properties.`$initial_pathname` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$lib_version` properties.`$lib_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_campaign` person_properties.`$initial_utm_campaign` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_medium` person_properties.`$initial_utm_medium` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_gclid` person_properties.`$initial_gclid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_gad_source` person_properties.`$initial_gad_source` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_source` person_properties.`$initial_utm_source` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_referring_domain` person_properties.`$initial_referring_domain` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_term` person_properties.`$initial_utm_term` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_utm_content` person_properties.`$initial_utm_content` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_gbraid` person_properties.`$initial_gbraid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_wbraid` person_properties.`$initial_wbraid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_msclkid` person_properties.`$initial_msclkid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_fbclid` person_properties.`$initial_fbclid` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$geoip_subdivision_1_code` properties.`$geoip_subdivision_1_code` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$prev_pageview_max_scroll_percentage` properties.`$prev_pageview_max_scroll_percentage` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$prev_pageview_max_content_percentage` properties.`$prev_pageview_max_content_percentage` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$prev_pageview_pathname` properties.`$prev_pageview_pathname` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_pathname` person_properties.`$initial_pathname` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$geoip_country_code` person_properties.`$geoip_country_code` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$browser_version` properties.`$browser_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$initial_current_url` person_properties.`$initial_current_url` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$current_url` person_properties.`$current_url` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$app_namespace` properties.`$app_namespace` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$os_name` properties.`$os_name` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$os_name` person_properties.`$os_name` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$app_version` person_properties.`$app_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$screen_height` properties.`$screen_height` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$screen_width` properties.`$screen_width` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$app_build` properties.`$app_build` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$geoip_country_code` properties.`$geoip_country_code` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$survey_id` properties.`$survey_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$survey_response_1` properties.`$survey_response_1` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$survey_response` properties.`$survey_response` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$el_text` properties.`$el_text` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$os_version` properties.`$os_version` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$feature_flag_payloads` properties.`$feature_flag_payloads` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$groups` properties.`$groups` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$feature_flag` properties.`$feature_flag` TYPE minmax GRANULARITY 1- , INDEX bf_active_feature_flags properties.`$active_feature_flags` TYPE bloom_filter(0.01) GRANULARITY 1- , INDEX `minmax_mat_$device_id` properties.`$device_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$geoip_continent_name` person_properties.`$geoip_continent_name` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$feature_flag_response` properties.`$feature_flag_response` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$referring_domain` person_properties.`$referring_domain` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$lib_version__minor` properties.`$lib_version__minor` TYPE minmax GRANULARITY 1- , INDEX minmax_inserted_at coalesce(inserted_at, _timestamp) TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$lib_custom_api_host` properties.`$lib_custom_api_host` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_pp_$geoip_country_name` person_properties.`$geoip_country_name` TYPE minmax GRANULARITY 1- , INDEX is_deleted_idx is_deleted TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$device` properties.`$device` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$exception_issue_id` properties.`$exception_issue_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$exception_fingerprint` properties.`$exception_fingerprint` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_LCP_value` properties.`$web_vitals_LCP_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_FCP_value` properties.`$web_vitals_FCP_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_CLS_value` properties.`$web_vitals_CLS_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$web_vitals_INP_value` properties.`$web_vitals_INP_value` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$viewport_width` properties.`$viewport_width` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$viewport_height` properties.`$viewport_height` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$anon_distinct_id` properties.`$anon_distinct_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_trace_id` properties.`$ai_trace_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_model` properties.`$ai_model` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_provider` properties.`$ai_provider` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_parent_id` properties.`$ai_parent_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_span_id` properties.`$ai_span_id` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$ai_http_status` properties.`$ai_http_status` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$process_person_profile` properties.`$process_person_profile` TYPE minmax GRANULARITY 1- , INDEX `minmax_mat_$app_version` properties.`$app_version` TYPE minmax GRANULARITY 1- , INDEX `bloom_mat_$is_identified` properties.`$is_identified` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$session_id_uuid` toUInt128(toUUIDOrNull(properties.`$session_id`)) TYPE minmax GRANULARITY 1- , INDEX `bloom_filter_$ai_trace_id` properties.`$ai_trace_id` TYPE bloom_filter(0.001) GRANULARITY 2- , INDEX `bloom_filter_$ai_session_id` properties.`$ai_session_id` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$ai_session_id` properties.`$ai_session_id` TYPE minmax GRANULARITY 1- , INDEX `set_$ai_is_error` properties.`$ai_is_error` TYPE set(7) GRANULARITY 1- , INDEX `minmax_mat_$ai_total_cost_usd` properties.`$ai_total_cost_usd` TYPE minmax GRANULARITY 1+, INDEX bloom_filter_distinct_id distinct_id TYPE bloom_filter GRANULARITY 1- , INDEX minmax_sharded_events_timestamp timestamp TYPE minmax GRANULARITY 1+ , INDEX bloom_filter_uuid uuid TYPE bloom_filter GRANULARITY 1+ , INDEX bloom_filter_person_id person_id TYPE bloom_filter GRANULARITY 1+ , INDEX minmax_captured_at captured_at TYPE minmax GRANULARITY 1+ , INDEX minmax_kafka_timestamp _timestamp TYPE minmax GRANULARITY 1+ , INDEX minmax_inserted_at inserted_at TYPE minmax GRANULARITY 1+ , INDEX minmax_timestamp timestamp TYPE minmax GRANULARITY 1, INDEX minmax_historical_migration historical_migration TYPE minmax GRANULARITY 1- , INDEX `bloom_mat_$feature_flag` properties.`$feature_flag` TYPE bloom_filter GRANULARITY 1- , INDEX `bloom_filter_$ai_prompt_name` properties.`$ai_prompt_name` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$ai_prompt_name` properties.`$ai_prompt_name` TYPE minmax GRANULARITY 1- , INDEX `bloom_filter_$ai_experiment_id` properties.`$ai_experiment_id` TYPE bloom_filter GRANULARITY 1- , INDEX `minmax_$ai_experiment_id` properties.`$ai_experiment_id` TYPE minmax GRANULARITY 1+ , INDEX minmax_created_at created_at TYPE minmax GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_{shard}/posthog.events_json', '{replica}', _timestamp)- PARTITION BY toYYYYMM(timestamp)- PRIMARY KEY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id))- ORDER BY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id), distinct_id, uuid)+ PARTITION BY clamp(toYYYYMM(timestamp), 202001, 203512)+ PRIMARY KEY (team_id, toDate(timestamp), event, cityHash64(distinct_id))+ ORDER BY (team_id, toDate(timestamp), event, cityHash64(distinct_id), timestamp, uuid)SAMPLE BY cityHash64(distinct_id)- SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', object_shared_data_serialization_version_for_zero_level_parts = 'map', merge_max_block_size = 131072, merge_max_block_size_bytes = 67108864, vertical_merge_algorithm_min_rows_to_activate = 0+ SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', enable_block_offset_column = 1, enable_block_number_column = 1, map_serialization_version = 'with_buckets', string_serialization_version = 'single_stream', propagate_types_serialization_versions_to_nested_types = 1'''# ---diff --git a/posthog/clickhouse/test/test_raw_sessions_model.py b/posthog/clickhouse/test/test_raw_sessions_model.pyindex 4a0837ce82b8..b1f0b222aa65 100644--- a/posthog/clickhouse/test/test_raw_sessions_model.py+++ b/posthog/clickhouse/test/test_raw_sessions_model.py@@ -2,6 +2,8 @@ import datetimefrom posthog.test.base import BaseTest, ClickhouseTestMixin, _create_event+from parameterized import parameterized+from posthog.clickhouse.client import query_with_columns, sync_executefrom posthog.models.raw_sessions.sessions_v2 import RAW_SESSION_TABLE_BACKFILL_SELECT_SQLfrom posthog.models.utils import uuid7@@ -333,22 +335,37 @@ class TestRawSessionsModel(ClickhouseTestMixin, BaseTest):self.assertEqual(len(responses), 1)self.assertEqual(responses[0]["vitals_lcp"], 42)- def test_backfill_sql(self):+ @parameterized.expand([None, "sharded_events"])+ def test_backfill_sql(self, events_table: str | None) -> None:distinct_id = create_distinct_id()session_id = create_session_id()_create_event(team=self.team,event="$pageview",distinct_id=distinct_id,- properties={"$current_url": "/", "$session_id": session_id},+ properties={+ "$current_url": "/",+ "$session_id": session_id,+ "$browser": "ExampleBrowser",+ "$viewport_width": 640.5,+ "$viewport_height": "invalid",+ "$web_vitals_LCP_value": 42.5,+ "$geoip_subdivision_city_name": "ExampleCity",+ },timestamp="2024-03-08",)- # just test that the backfill SQL can be run without error- sync_execute(- "INSERT INTO raw_sessions" + RAW_SESSION_TABLE_BACKFILL_SELECT_SQL() + "AND team_id = %(team_id)s",+ query = RAW_SESSION_TABLE_BACKFILL_SELECT_SQL(events_table=events_table) + "AND team_id = %(team_id)s"+ assert "toJSONString(properties)" not in query+ sync_execute("INSERT INTO raw_sessions" + query, {"team_id": self.team.id})+ results = sync_execute(+ f"""SELECT finalizeAggregation(browser), finalizeAggregation(viewport_width),+ finalizeAggregation(viewport_height), finalizeAggregation(vitals_lcp),+ finalizeAggregation(initial_geoip_subdivision_city_name)+ FROM ({query})""",{"team_id": self.team.id},)+ self.assertEqual(results, [("ExampleBrowser", 640, 0, 42.5, "ExampleCity")])def test_max_inserted_at(self):distinct_id = create_distinct_id()diff --git a/posthog/clickhouse/test/test_schema.py b/posthog/clickhouse/test/test_schema.pyindex c2c710c00ab1..d30746207dc4 100644--- a/posthog/clickhouse/test/test_schema.py+++ b/posthog/clickhouse/test/test_schema.py@@ -69,6 +69,9 @@ def test_events_json_table_uses_dedicated_kafka_consumer_group(settings):assert f"CREATE TABLE IF NOT EXISTS {KAFKA_EVENTS_NATIVE_JSON_TABLE}" in kafka_table_queryassert f"kafka_group_name = '{CONSUMER_GROUP_EVENTS_JSON_NATIVE_JSON}'" in kafka_table_queryassert f"FROM {settings.CLICKHOUSE_DATABASE}.{KAFKA_EVENTS_NATIVE_JSON_TABLE}" in mv_query+ assert "JSONCleanPostHogTemporaryProperties(" in mv_query+ assert "accurateCastOrNull(if(isValidJSON(source.properties)" in mv_query+ assert "accurateCastOrNull(if(isValidJSON(source.person_properties)" in mv_query@pytest.mark.parametrize(diff --git a/posthog/dags/data_deletion_requests.py b/posthog/dags/data_deletion_requests.pyindex 40c24edb2966..a51027aa9a73 100644--- a/posthog/dags/data_deletion_requests.py+++ b/posthog/dags/data_deletion_requests.py@@ -30,6 +30,7 @@ from posthog.clickhouse.adhoc_events_deletion import ADHOC_EVENTS_DELETION_TABLEfrom posthog.clickhouse.client import sync_executefrom posthog.clickhouse.client.connection import ClickHouseUserfrom posthog.clickhouse.cluster import AlterTableMutationRunner, ClickhouseCluster, LightweightDeleteMutationRunner+from posthog.clickhouse.events_json import UNPARSEABLE_PROPERTIES_KEYfrom posthog.clickhouse.workload import Workloadfrom posthog.dags.common import JobOwnersfrom posthog.dags.deletes import deletes_job@@ -164,11 +165,16 @@ def _property_filter_clause(props: list[str], prefix: str = "fp_", column: str =def _json_property_filter_clause(props: list[str], column: str = "properties") -> str:- """Presence clause for the native-JSON events tables, where JSONHas over the JSON column does- not see typed paths or nested objects — subcolumn reads are the reliable form."""+ """Find retained copies in native properties, mutation instructions, and quarantine."""exprs = [json_property_presence_expr(column, prop) for prop in props]- if len(exprs) == 1:- return exprs[0]+ # Malformed quarantine can contain any requested value, so its presence prevents verifying removal.+ exprs.append(json_property_presence_expr(column, UNPARSEABLE_PROPERTIES_KEY))+ temporary_props = (+ props+ if column == "properties"+ else [f"{instruction}.{prop}" for instruction in ("$set", "$set_once") for prop in props]+ )+ exprs.extend(json_property_presence_expr("temporary_properties", prop) for prop in temporary_props)return f"({' OR '.join(exprs)})"@@ -261,6 +267,8 @@ def _property_removal_where(if json_schemaelse _property_filter_clause(ctx.properties))+ elif json_schema and ctx.person_properties:+ presence_clauses.append(json_property_presence_expr("properties", UNPARSEABLE_PROPERTIES_KEY))if mat_cols:presence_clauses.extend(_mat_col_presence_clauses(mat_cols))if ctx.person_properties:@@ -622,7 +630,7 @@ def _refuse_property_removal_unsweepable()if not request.properties and not request.person_properties:return None- return _property_removal_where(request, inserted_at_max=marker_str)+ return _property_removal_where(request, inserted_at_max=marker_str, json_schema=target.uses_new_events_schema)_refuse_unsweepable(cluster, unsweepable, deletion_request, predicate_for, reason=_PROPERTY_REWRITE_UNSWEEPABLE_REASONdiff --git a/posthog/dags/tests/test_data_deletion_requests.py b/posthog/dags/tests/test_data_deletion_requests.pyindex 890efc848413..ebb69b092c20 100644--- a/posthog/dags/tests/test_data_deletion_requests.py+++ b/posthog/dags/tests/test_data_deletion_requests.py@@ -1,11 +1,13 @@import json+from concurrent.futures import Future+from contextlib import nullcontextfrom dataclasses import replacefrom datetime import UTC, datetime, timedeltafrom functools import partialfrom uuid import UUID, uuid4import pytest-from unittest.mock import patch+from unittest.mock import Mock, patchfrom django.conf import settings as django_settingsfrom django.utils import timezone@@ -15,7 +17,9 @@ from clickhouse_driver import Clientfrom dagster import build_op_contextfrom posthog.clickhouse.adhoc_events_deletion import ADHOC_EVENTS_DELETION_TABLE-from posthog.clickhouse.cluster import ClickhouseCluster, LightweightDeleteMutationRunner+from posthog.clickhouse.client import sync_execute+from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.cluster import ClickhouseCluster, LightweightDeleteMutationRunner, Queryfrom posthog.dags.data_deletion_requests import (DataDeletionRequestConfig,DeletionRequestContext,@@ -23,6 +27,7 @@ from posthog.dags.data_deletion_requests import (HogQLEventRemovalContext,PersonRemovalContext,_property_removal_where,+ _refuse_property_removal_unsweepable,auto_approve_deletion_requests_job,auto_approve_deletion_requests_schedule,data_deletion_request_event_removal,@@ -53,11 +58,17 @@ from posthog.models.data_deletion_request import ()from posthog.models.deletion_targets import (EVENTS,+ EVENTS_JSON,DeletionTarget,TargetPlacement,UnreachableTargetError,placement_for,)+from posthog.models.event.sql import (+ EVENTS_PROPERTIES_JSON_TYPE,+ PERSON_PROPERTIES_JSON_TYPE,+ json_property_presence_expr,+)from posthog.models.flag_evaluations.sql import FLAG_EVALUATIONS_DATA_TABLE, FLAG_EVALUATIONS_SOURCE_EVENTfrom posthog.models.person.bulk_delete import PersonDeletionFailure, PersonDeletionStep, PersonProfileDeletionResultfrom posthog.test.persons import create_person@@ -2711,6 +2722,64 @@ def _property_removal_ctx(**overrides) -> DeletionRequestContext:return replace(base, **overrides)+ "properties,person_properties,column,document,refuses",+ [+ (["$groups.organization"], [], "properties", '{"$groups":{"organization":"secret"}}', True),+ (["$feature/beta"], [], "properties", '{"$feature_flags":{"beta":"secret"}}', True),+ (["$set"], [], "temporary_properties", '{"$set":{"email":"[email protected]"}}', True),+ (["$feature_flag_request_id"], [], "temporary_properties", '{"$feature_flag_request_id":"id"}', True),+ (["secret"], [], "properties", '{"$unparseable_properties":"malformed secret"}', True),+ ([], ["secret"], "person_properties", '{"$unparseable_properties":"malformed secret"}', True),+ ([], ["email"], "properties", '{"$unparseable_properties":"malformed $set email"}', True),+ ([], ["email"], "temporary_properties", '{"$set_once":{"email":"[email protected]"}}', True),+ (["secret"], [], "temporary_properties", '{"$set":{"email":"[email protected]"}}', False),+ (["secret"], [], "properties", '{"other":"value"}', False),+ ],+)+def test_native_property_removal_gate_checks_retained_copies(+ properties: list[str], person_properties: list[str], column: str, document: str, refuses: bool+) -> None:+ marker_time = datetime(2026, 1, 1, tzinfo=UTC)+ marker = marker_time.strftime("%Y-%m-%d %H:%M:%S.%f")+ request = _property_removal_ctx(+ properties=properties,+ person_properties=person_properties,+ start_time=marker_time - timedelta(days=1),+ end_time=marker_time + timedelta(days=1),+ )+ stored = {"properties": "{}", "person_properties": "{}", "temporary_properties": "{}", column: document}++ def execute_query(query: Query, _role: NodeRole) -> Future[list[tuple[object, ...]]]:+ assert isinstance(query.parameters, dict)+ result: Future[list[tuple[object, ...]]] = Future()+ result.set_result(+ sync_execute(+ """WITH events_json AS (+ SELECT %(team_id)s AS team_id, '$pageview' AS event,+ toDateTime64(%(inserted_at_max)s, 6, 'UTC') AS timestamp,+ timestamp - INTERVAL 1 SECOND AS inserted_at, 1 AS _row_exists,+ CAST(%(properties)s, %(event_type)s) AS properties,+ CAST(%(person_properties)s, %(person_type)s) AS person_properties,+ CAST(%(temporary_properties)s, 'JSON(max_dynamic_paths=32)') AS temporary_properties+ ) """+ + query.query,+ {+ **query.parameters,+ **stored,+ "event_type": EVENTS_PROPERTIES_JSON_TYPE(),+ "person_type": PERSON_PROPERTIES_JSON_TYPE(),+ },+ )+ )+ return result++ cluster = Mock(spec=ClickhouseCluster)+ cluster.any_host_by_role.side_effect = execute_query+ with pytest.raises(dagster.Failure, match="cannot be deleted") if refuses else nullcontext():+ _refuse_property_removal_unsweepable(cluster, [EVENTS_JSON], request, marker)++def test_property_removal_where_scopes_to_events_by_default():sql, params = _property_removal_where(_property_removal_ctx())assert "AND event IN %(events)s" in sql@@ -2721,3 +2790,26 @@ def test_property_removal_where_omits_event_filter_when_delete_all_events():sql, params = _property_removal_where(_property_removal_ctx(events=[], delete_all_events=True))assert "event IN" not in sqlassert "events" not in params+++ "document,prop,expected",+ [+ ('{"$browser":"Chrome"}', "$groups.organization", 0),+ ('{"$browser":"Chrome"}', "$groups", 0),+ ('{"$groups":{"organization":"org1"}}', "$groups.organization", 1),+ ('{"$groups":{"custom_group":"g"}}', "$groups", 1),+ ('{"$browser":""}', "$browser", 0),+ ('{"custom":""}', "custom", 0),+ ('{"custom":{"a":""}}', "custom", 0),+ ('{"custom":{"a":"y"}}', "custom", 1),+ ],+)+def test_json_property_presence_expr_treats_empty_values_as_absent(document: str, prop: str, expected: int):+ predicate = json_property_presence_expr("properties", prop)+ [(present,)] = sync_execute(+ f"SELECT toUInt8({predicate}) FROM (SELECT CAST(%(raw)s, %(json_type)s) AS properties)",+ {"raw": document, "json_type": EVENTS_PROPERTIES_JSON_TYPE()},+ )++ assert present == expecteddiff --git a/posthog/hogql/ACCESS_CONTROL.md b/posthog/hogql/ACCESS_CONTROL.mdindex 8ddb561c0374..9c56a7119b6e 100644--- a/posthog/hogql/ACCESS_CONTROL.md+++ b/posthog/hogql/ACCESS_CONTROL.md@@ -188,6 +188,10 @@ They're masked when the query is printed to ClickHouse SQL, so a restricted readGroup restrictions retain their group type index, so a same-named property on another group type stays readable. The masking also applies to the Postgres-backed `system.groups.group_properties` field.+Native event JSON keeps parsing diagnostics in `$unparseable_properties`, which can embed raw property values as a string. If an event or person property is restricted, the shared restriction resolver also restricts that class's diagnostic marker. Blob reads omit it, and direct or JSON-extraction reads cannot retrieve it. Unrestricted readers retain diagnostic access.++Native reads of a parent containing restricted children use the masked JSON document instead of a raw subcolumn. This also covers multi-key `JSONHas` calls with computed keys. Unrestricted siblings remain readable.+The restriction set is loaded once per query in `prepare_ast_for_printing()` and cached per `(team_id, user_id)` for the request lifetime.### Coverage is per table, not per column namediff --git a/posthog/hogql/functions/udfs.py b/posthog/hogql/functions/udfs.pyindex 368509dea093..7b651e7ae3e0 100644--- a/posthog/hogql/functions/udfs.py+++ b/posthog/hogql/functions/udfs.py@@ -31,6 +31,7 @@ UDFS: dict[str, HogQLFunctionMeta] = {# JSONDropKeys is an executable UDF like the funnel UDFs, but it is printer-internal (restricted-property blob# stripping), not HogQL-exposed, so it lives outside UDFS. Its deployed name is versioned the same way.JSON_DROP_KEYS_CLICKHOUSE_NAME = "JSONDropKeys"+JSON_STRIP_EMPTY_STRINGS_AND_NULLS_CLICKHOUSE_NAME = "JSONStripEmptyStringsAndNulls"# We want CI to fail if there is a breaking change and the version hasn't been incrementedif is_cloud() or is_ci():diff --git a/posthog/hogql/printer/clickhouse.py b/posthog/hogql/printer/clickhouse.pyindex 649c3cf8e11c..fb3973bec6c1 100644--- a/posthog/hogql/printer/clickhouse.py+++ b/posthog/hogql/printer/clickhouse.py@@ -12,6 +12,7 @@ from posthog.hogql.context import HogQLContextfrom posthog.hogql.database.direct_sql_table import DirectSQLTablefrom posthog.hogql.database.models import (DANGEROUS_NoTeamIdCheckTable,+ DatabaseField,SavedQuery,StringJSONDatabaseField,StructDatabaseField,@@ -31,7 +32,10 @@ from posthog.hogql.escape_sql import ()from posthog.hogql.functions import ADD_OR_NULL_DATETIME_FUNCTIONS, FIRST_ARG_DATETIME_FUNCTIONSfrom posthog.hogql.functions.embed_text import resolve_embed_text-from posthog.hogql.functions.udfs import JSON_DROP_KEYS_CLICKHOUSE_NAME+from posthog.hogql.functions.udfs import (+ JSON_DROP_KEYS_CLICKHOUSE_NAME,+ JSON_STRIP_EMPTY_STRINGS_AND_NULLS_CLICKHOUSE_NAME,+)from posthog.hogql.helpers.timestamp_visitor import parse_zoned_datetime_stringfrom posthog.hogql.printer.base import BasePrinter, get_channel_definition_dict, resolve_field_typefrom posthog.hogql.printer.hogql import HogQLPrinter@@ -39,7 +43,6 @@ from posthog.hogql.restricted_properties import RESTRICTABLE_JSON_BLOB_COLUMNS,from posthog.hogql.type_system import parse_sql_runtime_typefrom posthog.hogql.visitor import GetFieldsTraverser, clone_expr-from posthog.clickhouse.events_json import EVENTS_PROPERTIES_JSON_SUBCOLUMNS, PERSON_PROPERTIES_JSON_SUBCOLUMNSfrom posthog.exchange_rate_constants import EXCHANGE_RATE_DECIMAL_PRECISION, EXCHANGE_RATE_DICTIONARY_NAMEfrom posthog.uuidt import UUIDTfrom posthog.week_start_day import WeekStartDay@@ -105,7 +108,26 @@ COLUMNS_WITH_HACKY_OPTIMIZED_NULL_HANDLING = {# The remaining values are structural literals of the dynamic-JSON property read, inlined to keep the printed# expression stable instead of burning parameters per property read.INLINE_SENTINEL_LITERALS = frozenset(- {"", "null", "true", "false", '^"|"$', "{}", "DateTime", "Array", "Map", "Tuple", " ", "T", '"'}+ {+ "",+ "null",+ "true",+ "false",+ '^"|"$',+ "{}",+ "DateTime",+ "Dynamic",+ "Float64",+ "Int64",+ "Array(String)",+ "[]",+ "Array",+ "Map",+ "Tuple",+ " ",+ "T",+ '"',+ })# Comparison ops where a datetime string with a timezone may be replaced by a datetime literal.@@ -502,6 +524,29 @@ class ClickHousePrinter(BasePrinter):def visit_field_type(self, type: ast.FieldType):field_sql = super().visit_field_type(type)+ if (+ self.context.uses_new_events_schema()+ and isinstance(type.table_type, ast.BaseTableType)+ and isinstance(type.table_type.resolve_database_table(self.context), EVENTS_TABLE_TYPES)+ and isinstance(field := type.resolve_database_field(self.context), DatabaseField)+ ):+ name = field.name+ if name in {+ "$session_id",+ "$window_id",+ "$session_id_uuid",+ "$group_0",+ "$group_1",+ "$group_2",+ "$group_3",+ "$group_4",+ }:+ # Proxy ALIAS expansion collides with aggregate outputs that reuse the column name.+ prefix = field_sql.removesuffix(self._print_identifier(name))+ path = "$session_id" if name == "$session_id_uuid" else name+ field_sql = f"{prefix}properties.{self._print_identifier(path)}"+ if name == "$session_id_uuid":+ field_sql = f"toUInt128(toUUIDOrNull({field_sql}))"field_sql = self._maybe_stringify_events_json_field(type, field_sql)return self._maybe_apply_json_drop_keys(type, field_sql)@@ -528,44 +573,19 @@ class ClickHousePrinter(BasePrinter):if not isinstance(type.table_type.resolve_database_table(self.context), EVENTS_TABLE_TYPES):return None- # toJSONString on a JSON column emits default values for every declared-but-absent typed path.- # Real JSON nulls cannot exist in the column, and typed path names are top-level, so dropping- # those declared defaults from a single serialization reproduces the original document.- filter_expr = self._events_json_serialized_pair_filter(resolved_field.name)- return (- "concat('{', arrayStringConcat("- "arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), "- f"arrayFilter(kv -> {filter_expr}, JSONExtractKeysAndValuesRaw(toJSONString({field_sql})))"- "), ','), '}')"- )-- def _events_json_serialized_pair_filter(self, field_name: str) -> str:- subcolumns = (- EVENTS_PROPERTIES_JSON_SUBCOLUMNS if field_name == "properties" else PERSON_PROPERTIES_JSON_SUBCOLUMNS+ serialized = (+ "concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), "+ f"arrayFilter(kv -> kv.2 != '[]', JSONExtractKeysAndValuesRaw(toJSONString({field_sql})))), ','), '}}')")- array_keys = []- map_keys = []- for key, column_type in subcolumns.items():- runtime_type = parse_sql_runtime_type(column_type)- if runtime_type.family == "array":- array_keys.append(key)- elif runtime_type.family == "map":- map_keys.append(key)-- filters = ["kv.2 != 'null'"]- if array_keys:- filters.append(f"NOT (kv.2 = '[]' AND has({self._clickhouse_string_array(array_keys)}, kv.1))")- if map_keys:- filters.append(f"NOT (kv.2 = '{{}}' AND has({self._clickhouse_string_array(map_keys)}, kv.1))")- return " AND ".join(filters)-- def _clickhouse_string_array(self, values: list[str]) -> str:- return "[" + ", ".join(escape_clickhouse_string(value) for value in values) + "]"+ return f"{JSON_STRIP_EMPTY_STRINGS_AND_NULLS_CLICKHOUSE_NAME}({serialized})"def _serialize_to_json_string_call(self, node: ast.Call) -> str | None:if node.name != "toJSONString" or len(node.args) != 1:return None- arg_type = resolve_field_type(node.args[0])+ arg = node.args[0]+ if isinstance(arg, ast.JsonSubcolumnAccess) and arg.access_type == "sub_object":+ return f"{JSON_STRIP_EMPTY_STRINGS_AND_NULLS_CLICKHOUSE_NAME}(toJSONString({self.visit(arg)}))"+ arg_type = resolve_field_type(arg)if not isinstance(arg_type, ast.FieldType):return Nonefield_sql = super().visit_field_type(arg_type)@@ -908,7 +928,7 @@ class ClickHousePrinter(BasePrinter):type_arg = node.args[1] if len(node.args) > 1 else Noneif not isinstance(type_arg, ast.Constant) or not isinstance(type_arg.value, str):raise QueryError(f"{node.name} requires a constant string type name as its second argument")- if parse_sql_runtime_type(type_arg.value).family == "unknown":+ if type_arg.value != "Dynamic" and parse_sql_runtime_type(type_arg.value).family == "unknown":raise QueryError(f"Unsupported type in {node.name}: '{type_arg.value}'")return super().visit_call(node)diff --git a/posthog/hogql/printer/test/test_printer.py b/posthog/hogql/printer/test/test_printer.pyindex 3b8af8b9d755..4611ea5b17a7 100644--- a/posthog/hogql/printer/test/test_printer.py+++ b/posthog/hogql/printer/test/test_printer.py@@ -2,6 +2,7 @@ import jsonfrom collections.abc import Callable, Mappingfrom datetime import datetimefrom typing import Any, Literal, Optional, cast+from uuid import UUIDimport pytestfrom posthog.test.base import (@@ -51,7 +52,7 @@ from posthog.hogql.context import HogQLContextfrom posthog.hogql.database.database import Databasefrom posthog.hogql.database.models import DateDatabaseField, StringDatabaseFieldfrom posthog.hogql.errors import ExposedHogQLError, ImpossibleASTError, QueryError-from posthog.hogql.escape_sql import escape_clickhouse_identifier, escape_clickhouse_string+from posthog.hogql.escape_sql import escape_clickhouse_identifierfrom posthog.hogql.modifiers import create_default_modifiers_for_teamfrom posthog.hogql.parser import parse_expr, parse_selectfrom posthog.hogql.printer import prepare_and_print_ast, prepare_ast_for_printing, print_prepared_ast, to_printed_hogql@@ -60,11 +61,7 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.client.execute import sync_executefrom posthog.models import PropertyDefinition-from posthog.models.event.sql import (- EVENTS_JSON_DATA_TABLE,- EVENTS_PROPERTIES_JSON_SUBCOLUMNS,- PERSON_PROPERTIES_JSON_SUBCOLUMNS,-)+from posthog.models.event.sql import EVENTS_JSON_DATA_TABLE, EVENTS_PROPERTIES_JSON_TYPEfrom posthog.models.exchange_rate.sql import EXCHANGE_RATE_DICTIONARY_NAMEfrom posthog.models.instance_setting import override_instance_configfrom posthog.models.team.team import WeekStartDay@@ -139,33 +136,6 @@ class TestPrinter(BaseTest):def _events_table_ref(self) -> str:return "events_json AS events" if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else "events"- def _json_reconstructed_blob(self, root: str) -> str:- return (- "concat('{', arrayStringConcat(arrayMap(kv -> concat(toJSONString(kv.1), ':', kv.2), "- + f"arrayFilter(kv -> {self._json_reconstructed_pair_filter(root)}, "- + f"JSONExtractKeysAndValuesRaw(toJSONString({root})))), ','), "- + "'}')"- )-- def _json_reconstructed_pair_filter(self, root: str) -> str:- subcolumns = (- PERSON_PROPERTIES_JSON_SUBCOLUMNS- if root.endswith("person_properties")- else EVENTS_PROPERTIES_JSON_SUBCOLUMNS- )- array_keys = [key for key, column_type in subcolumns.items() if column_type.startswith("Array(")]- map_keys = [key for key, column_type in subcolumns.items() if column_type.startswith("Map(")]-- filters = ["kv.2 != 'null'"]- if array_keys:- filters.append(f"NOT (kv.2 = '[]' AND has({self._clickhouse_string_array(array_keys)}, kv.1))")- if map_keys:- filters.append(f"NOT (kv.2 = '{{}}' AND has({self._clickhouse_string_array(map_keys)}, kv.1))")- return " AND ".join(filters)-- def _clickhouse_string_array(self, values: list[str]) -> str:- return "[" + ", ".join(escape_clickhouse_string(value) for value in values) + "]"-def _json_dynamic_subcolumn_expr(self, root: str, property_name: str) -> str:if "%" in property_name:subcolumns = [f"getSubcolumn({root}, %(hogql_val_{index})s)" for index in range(10)]@@ -972,7 +942,7 @@ class TestPrinter(BaseTest):def test_hogql_properties_use_active_storage_schema(self):context = HogQLContext(team_id=self.team.pk)expected_browser_sql = (- "events.properties.`$browser`"+ "nullIf(events.properties.`$browser`, '')"if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMAelse "replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', '')")@@ -986,7 +956,7 @@ class TestPrinter(BaseTest):context = HogQLContext(team_id=self.team.pk)expected_ai_trace_sql = (- "events.properties.`$ai_trace_id`"+ "nullIf(events.properties.`$ai_trace_id`, '')"if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMAelse "replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', '')")@@ -1030,10 +1000,8 @@ class TestPrinter(BaseTest):def test_hogql_property_comparisons_use_active_storage_schema(self):context = HogQLContext(team_id=self.team.pk)- # The isNotNull guard keeps the comparison non-nullable while the bare column read stays- # skip-index eligible — same shape as nullable materialized columns on the legacy schema.expected_sql = (- "and(equals(events.properties.`$browser`, %(hogql_val_0)s), isNotNull(events.properties.`$browser`))"+ "equals(events.properties.`$browser`, %(hogql_val_0)s)"if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMAelse "ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, %(hogql_val_0)s), ''), 'null'), '^\"|\"$', ''), %(hogql_val_1)s), 0)")@@ -1110,7 +1078,7 @@ class TestPrinter(BaseTest):self.assertEqual(self._expr("properties['$browser']"),(- "events.properties.`$browser`"+ "nullIf(events.properties.`$browser`, '')"if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMAelse "nullIf(nullIf(events.`mat_$browser`, ''), 'null')"),@@ -1426,15 +1394,14 @@ class TestPrinter(BaseTest):@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)def test_new_events_schema_json_has_uses_direct_json_subcolumns(self) -> None:- expected_by_expr = {- "JSONHas(properties, 'dynamic_key')": "or(isNotNull(events.properties.dynamic_key), notEquals(toJSONString(events.properties.^dynamic_key), '{}'))",- "JSONHas(properties, '$ai_trace_id')": "isNotNull(events.properties.`$ai_trace_id`)",- "JSONHas(properties, '$browser')": "isNotNull(events.properties.`$browser`)",- }- for expression, expected in expected_by_expr.items():+ for key in ("dynamic_key", "$ai_trace_id", "$browser", "$exception_list", "$feature_flags"):context = HogQLContext(team_id=self.team.pk, enable_select_queries=True)- printed = self._expr(expression, context)- self.assertEqual(printed, expected)+ printed = self._expr(f"JSONHas(properties, '{key}')", context)+ rows = sync_execute(+ f"SELECT {printed} FROM (SELECT CAST(arrayJoin(%(documents)s), %(json_type)s) AS properties) AS events",+ {**context.values, "documents": ["{}"], "json_type": EVENTS_PROPERTIES_JSON_TYPE()},+ )+ self.assertEqual(rows, [(0,)])self.assertNotIn("JSONExtractKeysAndValuesRaw", printed)context = HogQLContext(team_id=self.team.pk, enable_select_queries=True)@@ -1462,11 +1429,51 @@ class TestPrinter(BaseTest):self.assertNotIn("JSONExtractKeysAndValuesRaw", printed, expression)self.assertIn("events.properties.", printed, expression)+ @parameterized.expand(+ [+ (expression, properties)+ for expression in ["properties", "toJSONString(properties)"]+ for properties in [{}, {"$exception_types": ["TypeError"], "items": [None, "", {}, []], "custom_empty": []}]+ ]+ )@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)- def test_new_events_schema_to_json_string_scrubs_absent_typed_paths(self) -> None:- printed = self._expr("toJSONString(properties)")+ def test_new_events_schema_to_json_string_strips_empty_values(+ self, expression: str, properties: dict[str, object]+ ) -> None:+ printed = self._expr(expression)+ [(serialized,)] = sync_execute(+ f"SELECT {printed} FROM (SELECT CAST(%(raw)s, %(json_type)s) AS properties) AS events",+ {"raw": json.dumps(properties), "json_type": EVENTS_PROPERTIES_JSON_TYPE()},+ )+ self.assertEqual(json.loads(serialized), {key: value for key, value in properties.items() if value != []})- self.assertEqual(printed, self._json_reconstructed_blob("events.properties"))+ @parameterized.expand(+ [+ ({}, None, 0, 0),+ ({"$groups": {"project": "p"}}, {"project": "p"}, 1, 0),+ ({"$groups": {"organization": "o", "custom": "c"}}, {"organization": "o", "custom": "c"}, 1, 1),+ ]+ )+ @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)+ def test_new_events_schema_groups_omit_typed_defaults(+ self,+ properties: dict[str, object],+ expected_groups: dict[str, str] | None,+ has_groups: int,+ has_organization: int,+ ) -> None:+ context = HogQLContext(team_id=self.team.pk, enable_select_queries=True)+ printed = self._expr(+ "tuple(properties.$groups, JSONHas(properties, '$groups'), JSONHas(properties, '$groups', 'organization'), properties.$groups IS NULL, properties.$groups.organization)",+ context,+ )+ [(result,)] = sync_execute(+ f"SELECT {printed} FROM (SELECT CAST(%(raw)s, %(json_type)s) AS properties) AS events",+ {**context.values, "raw": json.dumps(properties), "json_type": EVENTS_PROPERTIES_JSON_TYPE()},+ )+ self.assertEqual(json.loads(result[0]) if result[0] is not None else None, expected_groups)+ self.assertEqual(result[1:4], (has_groups, has_organization, int(expected_groups is None)))+ self.assertEqual(result[4], (expected_groups or {}).get("organization"))def test_instance_setting_enables_new_events_schema(self) -> None:# The production rollout lever is the instance setting, not the env var — a fresh context@@ -1685,6 +1692,10 @@ class TestPrinter(BaseTest):else:assert "properties_group_custom" in enabled_response.clickhouseassert "properties_group_custom" in optimized_response.clickhouse+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ labels = labels - {"empty_string"}+ if "null" in labels:+ labels = labels | {"empty_string"}assert {row[0] for row in disabled_response.results} == labelsassert {row[0] for row in enabled_response.results} == labelsassert {row[0] for row in optimized_response.results} == labels@@ -3484,12 +3495,14 @@ class TestPrinter(BaseTest):# Verify the equals for $ai_trace_id is NOT wrapped in ifNull (it appears directly in WHERE clause)self.assertIn("WHERE and(equals(events.team_id,", sql)- # Direct property read should stay on the active indexed path with no sentinel scrubbing.+ # Native String paths represent missing values as empty strings.context = HogQLContext(team_id=self.team.pk)sql = self._expr("properties.$ai_trace_id", context)- self.assertEqual(sql.strip(), expected_expr)- self.assertNotIn("nullIf", sql)+ self.assertEqual(+ sql.strip(),+ f"nullIf({expected_expr}, '')" if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else expected_expr,+ )# IN operations - no ifNull wrappingcontext = HogQLContext(team_id=self.team.pk, enable_select_queries=True)@@ -3500,7 +3513,12 @@ class TestPrinter(BaseTest):assert trace1_param_key is not None, "Expected 'trace1' to be recorded as a parameter value"trace2_param_key = next((k for k, v in context.values.items() if v == "trace2"), None)assert trace2_param_key is not None, "Expected 'trace2' to be recorded as a parameter value"- self.assertIn(f"in({expected_expr}, tuple(%({trace1_param_key})s, %({trace2_param_key})s))", sql)+ expected_in = (+ f"has([%({trace1_param_key})s, %({trace2_param_key})s], {expected_expr})"+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA+ else f"in({expected_expr}, tuple(%({trace1_param_key})s, %({trace2_param_key})s))"+ )+ self.assertIn(expected_in, sql)self.assertNotIn("ifNull(in", sql)# NOT IN operations - no ifNull wrapping@@ -3563,12 +3581,14 @@ class TestPrinter(BaseTest):# Verify the equals for $ai_session_id is NOT wrapped in ifNull (it appears directly in WHERE clause)self.assertIn("WHERE and(equals(events.team_id,", sql)- # Direct property read should stay on the active indexed path with no sentinel scrubbing.+ # Native String paths represent missing values as empty strings.context = HogQLContext(team_id=self.team.pk)sql = self._expr("properties.$ai_session_id", context)- self.assertEqual(sql.strip(), expected_expr)- self.assertNotIn("nullIf", sql)+ self.assertEqual(+ sql.strip(),+ f"nullIf({expected_expr}, '')" if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else expected_expr,+ )# IN operations - no ifNull wrappingcontext = HogQLContext(team_id=self.team.pk, enable_select_queries=True)@@ -3579,7 +3599,12 @@ class TestPrinter(BaseTest):assert session1_param_key is not None, "Expected 'session1' to be recorded as a parameter value"session2_param_key = next((k for k, v in context.values.items() if v == "session2"), None)assert session2_param_key is not None, "Expected 'session2' to be recorded as a parameter value"- self.assertIn(f"in({expected_expr}, tuple(%({session1_param_key})s, %({session2_param_key})s))", sql)+ expected_in = (+ f"has([%({session1_param_key})s, %({session2_param_key})s], {expected_expr})"+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA+ else f"in({expected_expr}, tuple(%({session1_param_key})s, %({session2_param_key})s))"+ )+ self.assertIn(expected_in, sql)self.assertNotIn("ifNull(in", sql)if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:self.assertNotIn("mat_$ai_session_id", sql)@@ -4053,7 +4078,7 @@ class TestPrinter(BaseTest):settings=HogQLGlobalSettings(max_execution_time=10),)browser_expr = (- "events.properties.`$browser`"+ "nullIf(events.properties.`$browser`, '')"if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMAelse "nullIf(nullIf(events.`mat_$browser`, ''), 'null')")@@ -4082,7 +4107,7 @@ class TestPrinter(BaseTest):settings=HogQLGlobalSettings(max_execution_time=10),)browser_expr = (- "events.properties.`$browser`"+ "nullIf(events.properties.`$browser`, '')"if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMAelse "nullIf(nullIf(events.`mat_$browser`, ''), 'null')")@@ -5321,12 +5346,7 @@ class TestPrinter(BaseTest):# not block the uuid index."eq_property_access","properties.$session_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'",- (- "and(equals(events.`$session_id_uuid`, toUInt128(accurateCastOrNull(%(hogql_val_0)s, 'UUID'))), "- "isNotNull(events.properties.`$session_id`))"- )- if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA- else "equals(events.`$session_id_uuid`, toUInt128(accurateCastOrNull(%(hogql_val_0)s, 'UUID')))",+ "equals(events.`$session_id_uuid`, toUInt128(accurateCastOrNull(%(hogql_val_0)s, 'UUID')))",),("in_operation",@@ -5858,7 +5878,7 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):index_name = get_minmax_index_name(mat_col.name)if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:- expected_lt_mango = [("d_empty",), ("d_low",)]+ expected_lt_mango = [("d_low",)]expected_gte_mango = [("d_high",), ("d_mid",), ("d_null_str",)]lt_result = execute_hogql_query(@@ -5973,7 +5993,7 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):Expected behavior:- with_email: is_not_set=0 - property has a value- - test_with_empty_string: is_not_set=0 - property has a value+ - test_with_empty_string: is_not_set=1 for native String paths and materialized columns, otherwise 0- with_null: is_not_set=1 - null is treated as "not set"- without: is_not_set=1 - property doesn't exist@@ -6073,10 +6093,10 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):)assert result.clickhouse- # Materialized string columns use nullIf(nullIf(..., ''), 'null'), so empty strings become NULL.- materialized_column_nullifies_empty_string = is_materialized and (- not settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA- or poe_mode != PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS+ # Native String paths and materialized string columns use empty strings for missing values.+ materialized_column_nullifies_empty_string = is_materialized or (+ settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA+ and poe_mode == PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS)expected_results = {(distinct_id_with_email, "[email protected]", 0, 0),@@ -6099,6 +6119,7 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):and poe_mode == PersonsOnEventsMode.PERSON_ID_OVERRIDE_PROPERTIES_ON_EVENTS):assert "jsonextractraw" not in sql_lower+ assert "tojsonstring(events.person_properties)" not in sql_lowerelif not settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:# JSONHas is used in calculating is_not_set_result_historical, but nowhere elseassert sql_lower.count("jsonhas") == 1@@ -6582,6 +6603,8 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):and not settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA):ilike_expected = ilike_expected_if_non_nullable+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ ilike_expected = (ilike_expected | {""}) if pattern == "None" else ilike_expected - {""}pattern_expr = ast.Constant(value=pattern if pattern != "None" else None)ilike_result = execute_hogql_query(team=self.team,@@ -6677,6 +6700,8 @@ class TestMaterializedColumnOptimization(ClickhouseTestMixin, APIBaseTest):):in_expected = in_expected_if_non_nullable+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ in_expected = in_expected - {""}in_values_exprs: list[ast.Expr] = [ast.Constant(value=v) for v in in_values]in_tuple = ast.Tuple(exprs=in_values_exprs)@@ -6813,7 +6838,12 @@ class TestSessionIdUuidOptimization(ClickhouseTestMixin, APIBaseTest):event="$pageview",team=self.team,distinct_id="user1",- properties={"$session_id": self.SESSION_UUID_1, "color": "blue"},+ properties={+ "$session_id": self.SESSION_UUID_1,+ "$window_id": "window1",+ "$group_0": "group1",+ "color": "blue",+ },)_create_event(event="$pageview",@@ -6855,6 +6885,13 @@ class TestSessionIdUuidOptimization(ClickhouseTestMixin, APIBaseTest):"SELECT properties.color FROM events WHERE $session_id NOT IN ('{session_uuid_1}') AND $session_id = '{session_uuid_2}' ORDER BY properties.color",[("red",)],),+ (+ "aggregate_aliases",+ "SELECT argMin(e.$session_id, timestamp) AS $session_id, "+ "argMin(e.$window_id, timestamp) AS $window_id, argMin(e.$group_0, timestamp) AS $group_0, "+ "argMin(e.$session_id_uuid, timestamp) AS $session_id_uuid FROM events AS e WHERE properties.color = 'blue'",+ [(SESSION_UUID_1, "window1", "group1", UUID(SESSION_UUID_1).int)],+ ),])def test_session_id_uuid_query(self, _name, query_template, expected):diff --git a/posthog/hogql/property_planner.py b/posthog/hogql/property_planner.pyindex 617157c6bd4d..e809cac31615 100644--- a/posthog/hogql/property_planner.py+++ b/posthog/hogql/property_planner.py@@ -24,11 +24,7 @@ from posthog.hogql.type_system import (runtime_type_from_constant_type,)-from posthog.clickhouse.events_json import (- EVENTS_JSON_INDEXED_PROPERTY_NAMES,- EVENTS_PROPERTIES_JSON_SUBCOLUMNS,- PERSON_PROPERTIES_JSON_SUBCOLUMNS,-)+from posthog.clickhouse.events_json import EVENTS_JSON_INDEXED_PROPERTY_NAMESfrom posthog.clickhouse.materialized_column_types import MATERIALIZATION_VALID_TABLES, MaterializedColumnfrom posthog.clickhouse.property_groups import property_groupsfrom posthog.schema_enums import PropertyGroupsMode@@ -371,7 +367,7 @@ def _json_source_plan() -> PropertySourcePlan:has_minmax_index = _json_source_has_index(table_name, field_name, property_name, "minmax", context)has_bloom_filter_index = _json_source_has_index(table_name, field_name, property_name, "bloom_filter", context)- physical_type = _json_source_physical_type(table_name, field_name, property_name, context)+ physical_type = ast.StringType(nullable=True)return PropertySourcePlan(kind=PropertySourceKind.JSON,@@ -386,26 +382,6 @@ def _json_source_plan()-def _json_source_physical_type(- table_name: str | None,- field_name: str | None,- property_name: str | None,- context: HogQLContext | None,-) -> ast.ConstantType:- if context is None or not context.uses_new_events_schema():- return ast.StringType(nullable=True)- if table_name != "events" or field_name is None or property_name is None:- return ast.StringType(nullable=True)-- subcolumns = {- "properties": EVENTS_PROPERTIES_JSON_SUBCOLUMNS,- "person_properties": PERSON_PROPERTIES_JSON_SUBCOLUMNS,- }.get(field_name)- if subcolumns is None or property_name not in subcolumns:- return ast.StringType(nullable=True)- return constant_type_from_runtime_type(parse_sql_runtime_type(subcolumns[property_name]))--def _json_source_has_index(table_name: str | None,field_name: str | None,diff --git a/posthog/hogql/restricted_properties.py b/posthog/hogql/restricted_properties.pyindex fa493b080ce4..900976187dc6 100644--- a/posthog/hogql/restricted_properties.py+++ b/posthog/hogql/restricted_properties.py@@ -8,6 +8,7 @@ from posthog.hogql.database.schema.flag_evaluations import FlagEvaluationsTablefrom posthog.hogql.database.schema.groups import GroupsTable, RawGroupsTablefrom posthog.hogql.database.schema.persons import PersonsTable, RawPersonsTable+from posthog.clickhouse.events_json import UNPARSEABLE_PROPERTIES_KEYfrom posthog.constants import GROUP_TYPES_LIMITlogger = structlog.get_logger(__name__)@@ -112,7 +113,7 @@ def restricted_property_keys_for_table_type(# blob-key drop.return set()- return {+ restricted_keys = {restriction.namefor restriction in context.restricted_propertiesif restriction.property_type == prop_def_type@@ -122,3 +123,16 @@ def restricted_property_keys_for_table_type(or restriction.group_type_index == group_type_index)}+ if restricted_keys and context.uses_new_events_schema() and isinstance(table, (EventsTable, EventsPersonSubTable)):+ # Quarantine contains raw property values inside a string, beyond JSONDropKeys' reach.+ restricted_keys.add(UNPARSEABLE_PROPERTIES_KEY)+ return restricted_keys+++def native_property_path_overlaps_restriction(property_name: str, table_type: ast.Type, context: HogQLContext) -> bool:+ if not context.restricted_properties or not context.uses_new_events_schema():+ return False+ return any(+ property_name == key or property_name.startswith(key + ".") or key.startswith(property_name + ".")+ for key in restricted_property_keys_for_table_type(table_type, context)+ )diff --git a/posthog/hogql/test/test_index_eligibility.py b/posthog/hogql/test/test_index_eligibility.pyindex ece92f3a4e07..cad02f80bf4d 100644--- a/posthog/hogql/test/test_index_eligibility.py+++ b/posthog/hogql/test/test_index_eligibility.py@@ -3,6 +3,7 @@ from typing import castfrom posthog.test.base import BaseTestfrom unittest.mock import patch+from django.conf import settingsfrom django.test import SimpleTestCasefrom parameterized import parameterized@@ -408,9 +409,14 @@ class TestIndexEligibilityThroughThePlanner(BaseTest):)[predicate] = report.predicates- assert predicate.verdict == PredicateIndexVerdict.INDEXED- assert predicate.usable_indexes == (IndexKind.BLOOM_FILTER,)- assert report.usage == QueryIndexUsage.YES+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ assert predicate.verdict == PredicateIndexVerdict.UNINDEXED_JSON+ assert predicate.usable_indexes == ()+ assert report.usage == QueryIndexUsage.NO+ else:+ assert predicate.verdict == PredicateIndexVerdict.INDEXED+ assert predicate.usable_indexes == (IndexKind.BLOOM_FILTER,)+ assert report.usage == QueryIndexUsage.YESdef test_numeric_property_stored_as_string_is_blocked(self) -> None:report = self._report(@@ -420,7 +426,11 @@ class TestIndexEligibilityThroughThePlanner(BaseTest):)[predicate] = report.predicates- assert predicate.verdict == PredicateIndexVerdict.BLOCKED+ assert predicate.verdict == (+ PredicateIndexVerdict.UNINDEXED_JSON+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA+ else PredicateIndexVerdict.BLOCKED+ )assert predicate.usable_indexes == ()# The advice is real but not a query edit, so it must not become an editor marker.assert predicate.fix is not Nonediff --git a/posthog/hogql/test/test_modifiers.py b/posthog/hogql/test/test_modifiers.pyindex 2c373ebff30b..4a1f47f83e91 100644--- a/posthog/hogql/test/test_modifiers.py+++ b/posthog/hogql/test/test_modifiers.py@@ -17,7 +17,7 @@ from products.cohorts.backend.models.cohort import Cohortclass TestModifiers(BaseTest):def _expected_browser_select(self, materialization_mode: MaterializationMode) -> str:if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:- column = "events.properties.`$browser`"+ column = "nullIf(events.properties.`$browser`, '')"source = "events_json AS events"return f"SELECT {column} AS `$browser` FROM {source}"elif materialization_mode == MaterializationMode.DISABLED:@@ -40,7 +40,7 @@ class TestModifiers(BaseTest):if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:# Whole-blob person_properties reads are reconstructed from the JSON column; assert the# reconstruction reads the on-events column rather than pinning the full expression.- return "JSONExtractKeysAndValuesRaw(toJSONString(events.person_properties))"+ return "JSONStripEmptyStringsAndNulls(toJSONString(events.person_properties)) AS properties"return "events.person_properties AS properties"@override_settings(PERSON_ON_EVENTS_OVERRIDE=False, PERSON_ON_EVENTS_V2_OVERRIDE=False)diff --git a/posthog/hogql/test/test_property.py b/posthog/hogql/test/test_property.pyindex cb36858f266b..d8a82dc28771 100644--- a/posthog/hogql/test/test_property.py+++ b/posthog/hogql/test/test_property.py@@ -2265,7 +2265,12 @@ class TestPropertyIsSetIsNotSetWithData(APIBaseTest):self.test_cases: list[tuple[str, Any, PropertyType, Any]] = [# String type: value, empty, "null" literal, null, not set("string_value_prop", "hello", PropertyType.String, True),- ("string_empty_prop", "", PropertyType.String, self.ONLY_WHEN_NOT_LEGACY_MATERIALIZED),+ (+ "string_empty_prop",+ "",+ PropertyType.String,+ False if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else self.ONLY_WHEN_NOT_LEGACY_MATERIALIZED,+ ),("string_null_literal_prop", "null", PropertyType.String, self.ONLY_WHEN_NOT_LEGACY_MATERIALIZED),("string_null_prop", None, PropertyType.String, False),("string_not_set_prop", self.NOT_SET, PropertyType.String, False),@@ -2726,7 +2731,7 @@ class TestNegativeOperatorNullParityWithData(APIBaseTest):@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)-# $active_feature_flags is a native Array(String) subcolumn on the new events schema, so its negative+# $exception_types is a native Array(String) subcolumn on the new events schema, so its negative# multi-value filters compile through the arrayExists optimizer rather than a scalar comparison. These# execute against ClickHouse to prove the optimized path returns the right rows, not only the right SQL.class TestNegativeArrayOperatorNullParityWithData(APIBaseTest):@@ -2739,13 +2744,13 @@ class TestNegativeArrayOperatorNullParityWithData(APIBaseTest):team=cls.team,event=cls.EVENT,distinct_id="has_alpha",- properties={"$active_feature_flags": ["alpha", "gamma"]},+ properties={"$exception_types": ["alpha", "gamma"]},)_create_event(team=cls.team,event=cls.EVENT,distinct_id="no_alpha",- properties={"$active_feature_flags": ["beta", "gamma"]},+ properties={"$exception_types": ["beta", "gamma"]},)_create_event(team=cls.team, event=cls.EVENT, distinct_id="missing", properties={})@@ -2780,4 +2785,4 @@ class TestNegativeArrayOperatorNullParityWithData(APIBaseTest):])def test_array_operator_row_counts(self, _name: str, filter_fields: dict, expected_count: int):- assert self._count({"type": "event", "key": "$active_feature_flags", **filter_fields}) == expected_count+ assert self._count({"type": "event", "key": "$exception_types", **filter_fields}) == expected_countdiff --git a/posthog/hogql/test/test_query.py b/posthog/hogql/test/test_query.pyindex 33b94dcc872d..d5272e1480eb 100644--- a/posthog/hogql/test/test_query.py+++ b/posthog/hogql/test/test_query.py@@ -69,6 +69,23 @@ class TestQuery(ClickhouseTestMixin, APIBaseTest):maxDiff = Noneallow_dual_schema_snapshots = True+ @parameterized.expand(+ [+ ("having", "GROUP BY trace_id HAVING trace_id < 'c'", [("a", 1)]),+ ("having_all", "GROUP BY ALL HAVING trace_id < 'c'", [("a", 1)]),+ ("order_by", "GROUP BY trace_id ORDER BY trace_id < 'c' DESC", [("a", 1), ("z", 1)]),+ ]+ )+ def test_grouped_property_comparisons(self, _name: str, clause: str, expected: list[tuple[str, int]]) -> None:+ for trace_id in ("a", "z"):+ _create_event(team=self.team, event="test", distinct_id=trace_id, properties={"$ai_trace_id": trace_id})+ response = execute_hogql_query(+ "SELECT properties.$ai_trace_id AS trace_id, count() FROM events " + clause, team=self.team+ )+ self.assertEqual(response.results, expected)+ assert response.clickhouse is not None+ self.assertNotIn("toJSONString(events.properties)", response.clickhouse)+def _schema_snapshot(self, use_new_events_schema_snapshot: bool = False) -> Any:if not (use_new_events_schema_snapshot or getattr(self, "_use_new_events_schema_snapshots", False)):self.snapshot.session.pytest_session.config.option.warn_unused_snapshots = Truediff --git a/posthog/hogql/test/test_restricted_properties.py b/posthog/hogql/test/test_restricted_properties.pyindex 4feb46b15f87..6aeea11697fe 100644--- a/posthog/hogql/test/test_restricted_properties.py+++ b/posthog/hogql/test/test_restricted_properties.py@@ -1,6 +1,8 @@import refrom collections.abc import Iterator+import pytest+from posthog.hogql import astfrom posthog.hogql.context import HogQLContextfrom posthog.hogql.database.database import build_database_root_node@@ -97,7 +99,10 @@ def _blob_label(table: Table, column: str) -> str:return f"{table.to_printed_hogql()}.{column} ({type(table).__name__})"-def test_every_restrictable_blob_column_is_masked_with_the_keys_of_its_property_class():[email protected]("use_new_events_schema", [False, True])+def test_every_restrictable_blob_column_is_masked_with_the_keys_of_its_property_class(+ use_new_events_schema: bool,+) -> None:# The printer wraps a JSON blob in JSONDropKeys only when the column name is in# RESTRICTABLE_JSON_BLOB_COLUMNS *and* restricted_property_keys_for_table_type returns keys for the# table. The first half matches on a column name, the second on a table type, so either half can stop@@ -106,7 +111,11 @@ def test_every_restrictable_blob_column_is_masked_with_the_keys_of_its_property_# Comparing whole mappings holds both halves: a missing entry means a column left the name set, an entry# masking nothing means a catalog table has no dispatch branch, and a wrong value means a table reached# the wrong property class or group index.- context = HogQLContext(team_id=1, restricted_properties=_restrictions_covering_every_property_class())+ context = HogQLContext(+ team_id=1,+ restricted_properties=_restrictions_covering_every_property_class(),+ use_new_events_schema=use_new_events_schema,+ )masked: dict[str, frozenset[str]] = {}for table in _tables_in_node(build_database_root_node(include_posthog_tables=True)):@@ -125,4 +134,8 @@ def test_every_restrictable_blob_column_is_masked_with_the_keys_of_its_property_label = _blob_label(candidate, column)assert masked.setdefault(label, keys) == keys, f"{label} names blobs that mask different keys"- assert masked == {**_MASKED_BLOBS, **dict.fromkeys(_UNMASKED_BLOBS, frozenset())}+ expected = {**_MASKED_BLOBS, **dict.fromkeys(_UNMASKED_BLOBS, frozenset())}+ if use_new_events_schema:+ for label in ("events.properties (EventsTable)", "events.person_properties (EventsPersonSubTable)"):+ expected[label] |= {"$unparseable_properties"}+ assert masked == expecteddiff --git a/posthog/hogql/transforms/clickhouse_property_resolution.py b/posthog/hogql/transforms/clickhouse_property_resolution.pyindex f08519598395..3d258e658ab0 100644--- a/posthog/hogql/transforms/clickhouse_property_resolution.py+++ b/posthog/hogql/transforms/clickhouse_property_resolution.py@@ -21,18 +21,24 @@ so it treats both an empty string and the literal text `"null"` as "not set". Thexist in the blob" test, but tightening it would change query results."""-from dataclasses import dataclass+from collections.abc import Sequence+from dataclasses import dataclass, replacefrom typing import Literal, castfrom posthog.hogql import astfrom posthog.hogql.base import _T_AST+from posthog.hogql.constants import EXCEPTION_STRING_ARRAY_PROPERTIESfrom posthog.hogql.context import HogQLContextfrom posthog.hogql.database.models import DatabaseField, MapStringDatabaseFieldfrom posthog.hogql.errors import QueryErrorfrom posthog.hogql.functions.mapping import HOGQL_COMPARISON_MAPPINGfrom posthog.hogql.printer.base import resolve_field_typefrom posthog.hogql.printer.clickhouse import AI_BLOOM_FILTER_PROPERTIES, COLUMNS_WITH_HACKY_OPTIMIZED_NULL_HANDLING-from posthog.hogql.restricted_properties import mirrored_property_for_column, restricted_property_keys_for_table_type+from posthog.hogql.restricted_properties import (+ mirrored_property_for_column,+ native_property_path_overlaps_restriction,+ restricted_property_keys_for_table_type,+)from posthog.hogql.type_system import (ComparisonCompatibility,comparison_compatibility,@@ -43,11 +49,7 @@ from posthog.hogql.type_system import (from posthog.hogql.utils import ilike_matches, like_matchesfrom posthog.hogql.visitor import CloningVisitor, clone_expr-from posthog.clickhouse.events_json import (- DISTRIBUTED_EVENTS_JSON_TABLE,- EVENTS_PROPERTIES_JSON_SUBCOLUMNS,- PERSON_PROPERTIES_JSON_SUBCOLUMNS,-)+from posthog.clickhouse.events_json import DISTRIBUTED_EVENTS_JSON_TABLEfrom posthog.clickhouse.property_groups import property_groupsfrom posthog.clickhouse.workload import Workloadfrom posthog.schema_enums import MaterializationMode, PropertyGroupsMode@@ -56,7 +58,7 @@ from posthog.schema_enums import MaterializationMode, PropertyGroupsModeMAT_COL_NULL_SENTINELS = ["", "null"]MAX_MATERIALIZED_LIKE_PATTERN_LENGTH = 16 * 1024-# Leave the $ai_* bloom-filter columns to the printer: its comparison code already keeps them index-eligible+# Leave the legacy $ai_* bloom-filter columns to the printer: its comparison code already keeps them index-eligible# (`COLUMNS_WITH_HACKY_OPTIMIZED_NULL_HANDLING`, imported above so the two lists stay in sync). The value-read side skips# their nullIf scrubbing for the same reason, via `AI_BLOOM_FILTER_PROPERTIES` (the same columns, named as properties).@@ -111,7 +113,9 @@ def resolve_materialized_property_source(# read, comparison, key-existence). The column holds the raw value, so a comparison like `WHERE properties.x = 'y'`# could otherwise read it and probe the value. Declining here makes the comparison optimizers fall back; the read# itself becomes a constant NULL in `_substitute_value_read`.- if property_name in restricted_property_keys_for_table_type(field_type.table_type, context):+ if property_name in restricted_property_keys_for_table_type(+ field_type.table_type, context+ ) or native_property_path_overlaps_restriction(property_name, field_type.table_type, context):return Nonetable_type = _unwrap_to_table_type(field_type)@@ -167,34 +171,19 @@ def resolve_materialized_property_source(def resolve_json_subcolumn_source(field_type: ast.FieldType, table_name: str, field_name: str, property_name: str, context: HogQLContext) -> MaterializedPropertySource | None:- if property_name in restricted_property_keys_for_table_type(field_type.table_type, context):+ if native_property_path_overlaps_restriction(property_name, field_type.table_type, context):return Noneif not context.uses_new_events_schema():return Noneif table_name not in ("events", DISTRIBUTED_EVENTS_JSON_TABLE):return None- json_subcolumns_by_field = {- "properties": EVENTS_PROPERTIES_JSON_SUBCOLUMNS,- "person_properties": PERSON_PROPERTIES_JSON_SUBCOLUMNS,- }- if field_name not in json_subcolumns_by_field:+ if field_name not in ("properties", "person_properties"):return None- subcolumns = json_subcolumns_by_field[field_name]-- column_type = subcolumns.get(property_name)- if column_type is None:- return MaterializedPropertySource(- kind="json_subcolumn",- column=property_name,- is_nullable=True,- column_type="Dynamic",- )-return MaterializedPropertySource(kind="json_subcolumn",column=property_name,- is_nullable=column_type.startswith("Nullable("),- column_type=column_type,+ is_nullable=True,+ column_type="Dynamic",)@@ -320,7 +309,7 @@ def _materialized_head_expr(field_type,[first_key],source=source,- as_json=not is_single or _is_json_container_column(source),+ as_json=not is_single,)if source.kind == "property_group":@@ -360,24 +349,39 @@ def _materialized_head_expr(def _json_subcolumn_access(field_type: ast.FieldType,- keys: list[str],+ keys: Sequence[str | int],*,source: MaterializedPropertySource,is_nullable: bool,access_type: Literal["path", "sub_object"] = "path",-) -> ast.JsonSubcolumnAccess:- return ast.JsonSubcolumnAccess(+) -> ast.Expr:+ path: list[str] = []+ for key in keys:+ if not isinstance(key, str):+ break+ path.append(key)+ value: ast.Expr = ast.JsonSubcolumnAccess(expr=ast.Field(chain=[field_type.name], type=field_type),- keys=keys,+ keys=path,access_type=access_type,type=_column_constant_type_for_read(source, is_nullable=is_nullable),)+ for key in keys[len(path) :]:+ if isinstance(key, int):+ value = ast.ArrayAccess(array=value, property=ast.Constant(value=key), type=ast.StringType(nullable=True))+ else:+ value = ast.JsonSubcolumnAccess(expr=value, keys=[key], type=ast.StringType(nullable=True))+ return valuedef _dynamic_json_scalar_string_expr(value: ast.Expr, *, as_json: bool) -> ast.Expr:# Inspect the per-row variant only to choose its string format. Every branch casts the# whole Dynamic value, so mixed numeric variants are never filtered by a typed projection.- dynamic_type = ast.Call(name="dynamicType", args=[clone_expr(value)], type=ast.StringType(nullable=False))+ dynamic_type = ast.Call(+ name="dynamicType",+ args=[ast.Call(name="accurateCast", args=[clone_expr(value), _sentinel("Dynamic")])],+ type=ast.StringType(nullable=False),+ )datetime_string = ast.Call(name="replaceOne",args=[@@ -402,6 +406,11 @@ def _dynamic_json_scalar_string_expr(value: ast.Expr, *, as_json: bool) -> ast.Eargs=[clone_expr(value)],type=ast.StringType(nullable=False),)+ json_value = ast.Call(+ name="nullIf",+ args=[ast.Call(name="nullIf", args=[json_value, _sentinel("[]")]), _sentinel("{}")],+ type=ast.StringType(nullable=True),+ )scalar_expr: ast.Expr = json_valueif not as_json:scalar_expr = ast.Call(@@ -463,52 +472,35 @@ def _dynamic_json_object_string_expr(def _json_subcolumn_value_expr(field_type: ast.FieldType,- keys: list[str],+ keys: Sequence[str | int],*,source: MaterializedPropertySource,as_json: bool = False,) -> ast.Expr:- value = _json_subcolumn_access(field_type, keys, source=source, is_nullable=source.is_nullable)- if _is_dynamic_json_source(source):- object_value = _dynamic_json_object_string_expr(field_type, keys, source=source)- object_present = _call("notEquals", [clone_expr(object_value), _sentinel("{}")])- scalar_value = _dynamic_json_scalar_string_expr(value, as_json=as_json)- scalar_or_null = ast.Call(- name="if",- args=[- ast.Call(name="isNull", args=[clone_expr(value)]),- ast.Constant(value=None, type=ast.StringType(nullable=True)),- scalar_value,- ],- type=ast.StringType(nullable=True),- )- return ast.Call(- name="if",- args=[- object_present,- object_value,- scalar_or_null,- ],- type=ast.StringType(nullable=True),- )- if as_json:- serialized = ast.Call(- name="toJSONString", args=[clone_expr(value)], type=ast.StringType(nullable=source.is_nullable)- )- if _is_json_container_column(source) and not source.is_nullable:- # Declared arrays and maps cannot distinguish a missing path from an explicitly empty value.- # Both are intentionally treated as NULL, matching materialized-column behavior.- return ast.Call(- name="if",+ value = _json_subcolumn_access(field_type, keys, source=source, is_nullable=True)+ scalar_value = _dynamic_json_scalar_string_expr(value, as_json=as_json)+ scalar_or_null = ast.Call(+ name="if",+ args=[+ ast.Call(+ name="isNull",args=[- ast.Call(name="empty", args=[value], type=ast.BooleanType(nullable=False)),- ast.Constant(value=None, type=ast.StringType(nullable=True)),- serialized,+ ast.Call(name="nullIf", args=[ast.Call(name="toString", args=[clone_expr(value)]), _sentinel("")])],- type=ast.StringType(nullable=True),- )- return serialized- return value+ ),+ ast.Constant(value=None, type=ast.StringType(nullable=True)),+ scalar_value,+ ],+ type=ast.StringType(nullable=True),+ )+ if any(isinstance(key, int) for key in keys):+ return scalar_or_null+ object_value = _dynamic_json_object_string_expr(field_type, list(cast(Sequence[str], keys)), source=source)+ return ast.Call(+ name="if",+ args=[_call("notEquals", [clone_expr(object_value), _sentinel("{}")]), object_value, scalar_or_null],+ type=ast.StringType(nullable=True),+ )def _map_value_read(blob: ast.Expr, key: str) -> ast.Expr:@@ -562,34 +554,8 @@ def _substitute_value_read(node: ast.PropertyAccess, context: HogQLContext) -> a_record_property_usage(context, source.kind)- if source.kind == "json_subcolumn" and deeper_keys:- if not _is_dynamic_json_source(source):- subcolumn_head = _json_subcolumn_value_expr(- field_type,- [first_key],- source=source,- as_json=not _is_string_column(source),- )- return ast.PropertyAccess(expr=subcolumn_head, keys=deeper_keys, type=ast.StringType(nullable=True))-- subcolumn_keys = [first_key]- remaining_keys: list[str | int] = []- for index, key in enumerate(deeper_keys):- if isinstance(key, str):- subcolumn_keys.append(key)- continue- remaining_keys = deeper_keys[index:]- break-- subcolumn_head = _json_subcolumn_value_expr(- field_type,- subcolumn_keys,- source=source,- as_json=bool(remaining_keys),- )- if not remaining_keys:- return subcolumn_head- return ast.PropertyAccess(expr=subcolumn_head, keys=remaining_keys, type=ast.StringType(nullable=True))+ if source.kind == "json_subcolumn":+ return _json_subcolumn_value_expr(field_type, node.keys, source=source)head = _materialized_head_expr(source,@@ -682,10 +648,6 @@ def _is_string_array_column(source: MaterializedPropertySource) -> bool:)-def _is_json_container_column(source: MaterializedPropertySource) -> bool:- return parse_sql_runtime_type(source.column_type or "String").family in ("array", "map", "tuple")--def _is_dynamic_json_source(source: MaterializedPropertySource) -> bool:return source.kind == "json_subcolumn" and source.column_type == "Dynamic"@@ -748,12 +710,16 @@ class _OptimizableProperty:map column for a property group, where a missing key reads as the '' default rather than SQL NULL."""if self.source.kind == "json_subcolumn":- return _json_subcolumn_access(- self.field_type,- [self.key],- source=self.source,- is_nullable=False,- )+ value = _json_subcolumn_access(self.field_type, [self.key], source=self.source, is_nullable=False)+ if _is_string_array_column(self.source):+ return ast.Call(+ name="accurateCast",+ args=[+ ast.Call(name="ifNull", args=[value, ast.Constant(value=[])]),+ _sentinel("Array(String)"),+ ],+ )+ return valuefield = _synthetic_column_field(self.field_type, self.source.column, is_nullable=False)assert field is not None # the source was resolved from this same field_type@@ -809,6 +775,7 @@ class ClickHousePropertyResolver(CloningVisitor):# Depth of `indexHint(...)` calls above the node being visited. A hint is an optimizer directive only, so a# comparison inside one must not grow a second, nested hint.self._index_hint_depth = 0+ self._in_grouped_clause = Falsedef visit_select_query(self, node: ast.SelectQuery) -> ast.SelectQuery:scope: set[int] = set()@@ -820,9 +787,18 @@ class ClickHousePropertyResolver(CloningVisitor):table_type = getattr(table_type, "table_type", None)join = join.next_joinself._tables_in_scope.append(scope)+ was_in_grouped_clause = self._in_grouped_clause+ self._in_grouped_clause = Falsetry:- return super().visit_select_query(node)+ if not node.group_by and node.group_by_mode != "all":+ return super().visit_select_query(node)+ result = super().visit_select_query(replace(node, having=None, order_by=None))+ self._in_grouped_clause = True+ result.having = self.visit(node.having)+ result.order_by = [self.visit(expr) for expr in node.order_by] if node.order_by else None+ return resultfinally:+ self._in_grouped_clause = was_in_grouped_clauseself._tables_in_scope.pop()def _property_table_in_scope(self, field_type: ast.FieldType) -> bool:@@ -856,6 +832,9 @@ class ClickHousePropertyResolver(CloningVisitor):Only a single-key access (`properties.x`, no deeper `.a.b`) maps to one backing column. A multi-key access readsthe column and then JSON-extracts deeper, so it can't use the bare-column comparison rewrites."""+ # Bare-column rewrites after aggregation can reference a column absent from GROUP BY.+ if self._in_grouped_clause:+ return Nonenode = self._lowered_property_operand(expr)if node is not None and len(node.keys) == 1:field_type = _blob_field_type_of(node)@@ -937,6 +916,28 @@ class ClickHousePropertyResolver(CloningVisitor):finally:self._index_hint_depth -= 1+ if node.name in ("toFloat", "toInt") and len(node.args) == 1:+ access = self._lowered_property_operand(node.args[0])+ if access is not None:+ field_type = _blob_field_type_of(access)+ assert field_type is not None+ source = resolve_materialized_property_source(+ field_type,+ str(access.keys[0])+ if any(isinstance(key, int) for key in access.keys)+ else ".".join(cast(list[str], access.keys)),+ self.context,+ )+ if source is not None and source.kind == "json_subcolumn":+ return ast.Call(+ name="accurateCastOrNull",+ args=[+ _json_subcolumn_access(field_type, access.keys, source=source, is_nullable=True),+ _sentinel("Float64" if node.name == "toFloat" else "Int64"),+ ],+ type=node.type,+ )+json_string_on_events_json = self._rewrite_to_json_string_on_events_json_subcolumn(node)if json_string_on_events_json is not None:return json_string_on_events_json@@ -1008,7 +1009,7 @@ class ClickHousePropertyResolver(CloningVisitor):return Nonerequested_type = parse_sql_runtime_type(type_arg.value)- if requested_type.family not in ("array", "map", "tuple"):+ if requested_type.family != "array":return Nonesource_arg = node.args[0]@@ -1028,15 +1029,20 @@ class ClickHousePropertyResolver(CloningVisitor):if source is None or source.kind != "json_subcolumn":return None- source_type = parse_sql_runtime_type(source.column_type or "String")- if (- source_type.family == "array"- and requested_type.family == "array"- and source_type.item_type is not None- and requested_type.item_type is not None- and source_type.item_type.family == requested_type.item_type.family- ):- return _json_subcolumn_access(field_type, [property_name], source=source, is_nullable=False)+ string_array = self._materialized_string_array_property(source_arg.args[0])+ if string_array is not None:+ source_type = parse_sql_runtime_type(string_array.source.column_type or "String")+ if (+ source_type.item_type is not None+ and requested_type.item_type is not None+ and source_type.item_type.family == requested_type.item_type.family+ ):+ return _json_subcolumn_access(+ string_array.field_type,+ [string_array.key],+ source=string_array.source,+ is_nullable=False,+ )json_value = _json_subcolumn_value_expr(field_type,@@ -1092,12 +1098,16 @@ class ClickHousePropertyResolver(CloningVisitor):first_key = first_key_arg.valueif first_key in restricted_property_keys_for_table_type(field_type.table_type, self.context):return ast.Constant(value=False, type=ast.BooleanType(nullable=False))+ if native_property_path_overlaps_restriction(first_key, field_type.table_type, self.context):+ # Read the masked document so nested and computed keys cannot inspect a restricted child.+ return Nonesource = resolve_json_subcolumn_source(field_type, table_type.table.to_printed_clickhouse(self.context), field.name, first_key, self.context)- if source is None:- return None+ # Every key on the JSON tables resolves to a declared or Dynamic subcolumn. Leaving the call on the blob+ # would serialize the whole document per row, so a missing source is a bug, not a fallback.+ assert source is not Noneif len(node.args) > 2:json_value = _json_subcolumn_value_expr(@@ -1126,27 +1136,7 @@ class ClickHousePropertyResolver(CloningVisitor):filter_expr=node.filter_expr,)- subcolumn = _json_subcolumn_access(field_type, [first_key], source=source, is_nullable=source.is_nullable)- if _is_dynamic_json_source(source):- object_value = _dynamic_json_object_string_expr(field_type, [first_key], source=source)- return _call(- "or",- [- _call("isNotNull", [subcolumn]),- _call("notEquals", [object_value, _sentinel("{}")]),- ],- )- if source.is_nullable or _is_dynamic_json_source(source):- return _call("isNotNull", [subcolumn])- if _is_string_array_column(source):- return _call("notEmpty", [subcolumn])- if _is_string_column(source):- return ast.Call(- name="notEquals",- args=[_call("length", [subcolumn]), _const(0)],- type=ast.BooleanType(nullable=False),- )- return None+ return _call("isNotNull", [_json_subcolumn_value_expr(field_type, [first_key], source=source)])def visit_compare_operation(self, node: ast.CompareOperation) -> ast.Expr:# Try each skip-index comparison rewrite in order. Each one consumes the property operand and returns the@@ -1345,12 +1335,19 @@ class ClickHousePropertyResolver(CloningVisitor):return Nonefield_type, property_name = singlesource = resolve_materialized_property_source(field_type, property_name, self.context)- if source is None or source.kind != "json_subcolumn" or not _is_string_array_column(source):+ if source is None or source.kind != "json_subcolumn":+ return None+ property_info = (+ self.context.property_metadata.event_properties.get(property_name, {})+ if self.context.property_metadata+ else {}+ )+ if property_name not in EXCEPTION_STRING_ARRAY_PROPERTIES and property_info.get("type") != "Array":return Nonereturn _OptimizableProperty(field_type=field_type,key=property_name,- source=source,+ source=replace(source, column_type="Array(String)"),)def _property_group_property(self, expr: ast.Expr) -> _OptimizableProperty | None:@@ -1372,7 +1369,10 @@ class ClickHousePropertyResolver(CloningVisitor):@staticmethoddef _is_ai_column(source: MaterializedPropertySource) -> bool:- return source.column.strip("`\"'") in COLUMNS_WITH_HACKY_OPTIMIZED_NULL_HANDLING+ return (+ source.kind != "json_subcolumn"+ and source.column.strip("`\"'") in COLUMNS_WITH_HACKY_OPTIMIZED_NULL_HANDLING+ )# --- property-group optimizers ---diff --git a/posthog/hogql/transforms/property_types.py b/posthog/hogql/transforms/property_types.pyindex d650324a656f..72dbff78a621 100644--- a/posthog/hogql/transforms/property_types.py+++ b/posthog/hogql/transforms/property_types.py@@ -24,7 +24,6 @@ from posthog.hogql.restricted_properties import restricted_property_keys_for_tabfrom posthog.hogql.type_system import normalized_runtime_type, parse_sql_runtime_typefrom posthog.hogql.visitor import CloningVisitor, TraversingVisitor-from posthog.clickhouse.events_json import EVENTS_PROPERTIES_JSON_SUBCOLUMNS, PERSON_PROPERTIES_JSON_SUBCOLUMNSfrom posthog.clickhouse.materialized_column_types import MATERIALIZATION_VALID_TABLES, MaterializedColumnfrom posthog.dataclasses import frozen@@ -465,17 +464,11 @@ class PropertySwapper(CloningVisitor):chain=[*field_arg.chain, first_key],type=ast.PropertyType(chain=[first_key], field_type=field_type),)- subcolumns = (- EVENTS_PROPERTIES_JSON_SUBCOLUMNS if field_type.name == "properties" else PERSON_PROPERTIES_JSON_SUBCOLUMNS+ property_document: ast.Expr = ast.Call(+ name="toJSONString",+ args=[property_field],+ type=ast.StringType(nullable=True),)- declared_type = subcolumns.get(first_key)- property_document: ast.Expr = property_field- if len(property_path) == 1 or declared_type not in ("String", "Nullable(String)"):- property_document = ast.Call(- name="toJSONString",- args=[property_field],- type=ast.StringType(nullable=True),- )property_document = ast.Call(name="ifNull",args=[diff --git a/posthog/hogql/transforms/test/test_property_types.py b/posthog/hogql/transforms/test/test_property_types.pyindex 8b8352634483..d924354c9704 100644--- a/posthog/hogql/transforms/test/test_property_types.py+++ b/posthog/hogql/transforms/test/test_property_types.py@@ -53,7 +53,7 @@ from posthog.hogql.type_system import ComparisonCompatibilityfrom posthog.clickhouse.client import sync_executefrom posthog.models import PropertyDefinition, Team-from posthog.models.event.sql import DISTRIBUTED_EVENTS_JSON_TABLE+from posthog.models.event.sql import EVENTS_PROPERTIES_JSON_TYPE, PERSON_PROPERTIES_JSON_TYPEfrom posthog.models.group.util import create_groupfrom posthog.models.property.util import get_property_string_exprfrom posthog.test.test_utils import create_group_type_mapping_without_created_at@@ -77,6 +77,7 @@ def _normalize_snapshot_sql(sql: str) -> str:return "\n".join(line.rstrip() for line in sql.splitlines())+@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)class TestNewEventsSchemaArraySubcolumns(SimpleTestCase):def _context(self) -> HogQLContext:team = Team(id=1, project_id=1)@@ -106,75 +107,98 @@ class TestNewEventsSchemaArraySubcolumns(SimpleTestCase):assert plan is not Nonereturn plan- @parameterized.expand(- [- ("$active_feature_flags", "beta-feature", True),- ("$exception_types", "TypeError", False),- ]- )- @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)- def test_property_comparison_planner_uses_json_array_subcolumn_type(- self, property_name: str, value: str, has_bloom_filter_index: bool- ) -> None:- plan = self._plan_where_comparison(f"select count() from events where properties.{property_name} = '{value}'")+ def test_property_comparison_planner_does_not_depend_on_json_storage_type(self) -> None:+ plan = self._plan_where_comparison("select count() from events where properties.$exception_types = 'TypeError'")assert plan.access.source.kind == PropertySourceKind.JSON- assert plan.access.source.is_nullable is False- assert isinstance(plan.access.source.physical_type, ast.ArrayType)- assert isinstance(plan.access.source.physical_type.item_type, ast.StringType)- assert plan.access.source.has_bloom_filter_index is has_bloom_filter_index+ dynamic_plan = self._plan_where_comparison(+ "select count() from events where properties.custom_array = 'TypeError'"+ )+ assert plan.access.source.is_nullable is True+ assert plan.access.source.physical_type == dynamic_plan.access.source.physical_type+ assert plan.access.source.has_bloom_filter_index is False- @parameterized.expand(- [- ("json_has", "select count() from events where JSONHas(properties, '$active_feature_flags')", "notEmpty"),- (- "is_set",- "select count() from events where properties.$active_feature_flags != null",- "notEmpty",- ),- (- "is_not_set",- "select count() from events where properties.$active_feature_flags = null",- "empty",- ),- (- "exact",- "select count() from events where properties.$active_feature_flags = 'beta-feature'",- "has",- ),- (- "in",- "select count() from events where properties.$active_feature_flags in ('alpha', 'beta')",- "hasAny",- ),- (- "icontains",- "select count() from events where toString(properties.$active_feature_flags) ILIKE '%beta%'",- "arrayExists",- ),- (- "icontains_multi",- "select count() from events where multiSearchAnyCaseInsensitive(toString(properties.$active_feature_flags), ['alpha', 'beta']) > 0",- "arrayExists",- ),- ]- )- @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)- def test_active_feature_flags_use_array_subcolumn(self, _name: str, query: str, expected_function: str) -> None:- printed = self._print_select(query)+ @parameterized.expand([("declared", EVENTS_PROPERTIES_JSON_TYPE()), ("dynamic", "JSON")])+ def test_string_paths_read_empty_as_null(self, _name: str, json_type: str) -> None:+ context = self._context()+ with patch("posthog.hogql.printer.utils.build_property_swapper"):+ printed, _ = prepare_and_print_ast(+ parse_select(+ "SELECT properties.$browser, properties.$browser IS NULL, "+ "properties.$browser IS NOT NULL FROM events"+ ),+ context,+ "clickhouse",+ )+ rows = sync_execute(+ "WITH events_json AS (SELECT 1 AS team_id, CAST(arrayJoin(%(documents)s), %(json_type)s) AS properties) "+ + printed,+ {+ **context.values,+ "json_type": json_type,+ "documents": [+ "{}",+ '{"$browser":""}',+ '{"$browser":"null"}',+ '{"$browser":"Chrome"}',+ '{"$browser":"[]"}',+ '{"$browser":"{}"}',+ ],+ },+ )+ assert rows == [(None, 1, 0), (None, 1, 0), ("null", 0, 1), ("Chrome", 0, 1), ("[]", 0, 1), ("{}", 0, 1)]- assert expected_function in printed, printed- assert "events.properties.`$active_feature_flags`" in printed, printed- assert "toString(events.properties.`$active_feature_flags`)" not in printed, printed- assert "JSONHas(events.properties" not in printed, printed+ @parameterized.expand([("declared", EVENTS_PROPERTIES_JSON_TYPE()), ("dynamic", "JSON")])+ def test_numeric_casts_preserve_mixed_native_types(self, _name: str, json_type: str) -> None:+ context = self._context()+ with patch("posthog.hogql.printer.utils.build_property_swapper"):+ printed, _ = prepare_and_print_ast(+ parse_select(+ "SELECT toFloat(properties.$screen_height), toFloat(properties.custom), "+ "toFloat(properties.nested.score), toFloat(properties.numbers[1]), toFloat(properties.objects[1].score) FROM events"+ ),+ context,+ "clickhouse",+ )+ for unwanted in ("dynamicElement", "JSONExtract", "replaceRegexpAll", "toJSONString"):+ assert unwanted not in printed, printed+ values = [42, 2**63, 2.5, "3.75", "invalid", None, ""]+ rows = sync_execute(+ "WITH events_json AS (SELECT 1 AS team_id, CAST(arrayJoin(%(documents)s), %(json_type)s) AS properties) "+ + printed,+ {+ **context.values,+ "json_type": json_type,+ "documents": [+ json.dumps(+ {+ "$screen_height": value,+ "custom": value,+ "nested": {"score": value},+ "numbers": [value],+ "objects": [{"score": value}],+ }+ )+ for value in values+ ],+ },+ )+ assert rows == [+ (42.0,) * 5,+ (float(2**63),) * 5,+ (2.5,) * 5,+ (3.75,) * 5,+ (None,) * 5,+ (None,) * 5,+ (None,) * 5,+ ]- @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)def test_negative_multi_icontains_array_property_stays_optimized(self) -> None:where = property_to_expr({"type": "event",- "key": "$active_feature_flags",- "value": ["alpha", "beta"],+ "key": "$exception_types",+ "value": ["TypeError", "ValueError"],"operator": "not_icontains_multi",},team=Team(id=1, project_id=1),@@ -191,13 +215,12 @@ class TestNewEventsSchemaArraySubcolumns(SimpleTestCase):# array optimizer, which then falls back to multiSearchAnyCaseInsensitive(toString(…)) over the# array serialized to JSON text instead of an element-wise arrayExists scan.assert "arrayExists" in printed, printed- assert "events.properties.`$active_feature_flags`" in printed, printed- assert "multiSearchAnyCaseInsensitive(toString(" not in printed, printed+ assert "events.properties.`$exception_types`" in printed, printed+ assert "toString(events.properties.`$exception_types`)" not in printed, printed# The missing-property branch must resolve to empty(column), not isNull(toJSONString(column)),# or every row pays to serialize the array just to null-check it.assert "toJSONString" not in printed, printed- @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)def test_exception_types_use_array_subcolumn(self) -> None:printed = self._print_select("select count() from events where properties.$exception_types = 'TypeError'")@@ -208,11 +231,10 @@ class TestNewEventsSchemaArraySubcolumns(SimpleTestCase):@parameterized.expand([- ("typed_array", "$active_feature_flags"),+ ("typed_array", "$exception_types"),("dynamic_array", "custom_array"),])- @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)def test_array_value_reads_are_json_strings(self, _name: str, property_name: str) -> None:printed = self._print_select(f"select lower(properties.{property_name}) from events")escaped_property_name = f"`{property_name}`" if property_name.startswith("$") else property_name@@ -222,7 +244,7 @@ class TestNewEventsSchemaArraySubcolumns(SimpleTestCase):@parameterized.expand([- ("typed_array", "$active_feature_flags"),+ ("typed_array", "$exception_types"),("dynamic_array", "custom_array"),])@@ -239,21 +261,103 @@ class TestNewEventsSchemaArraySubcolumns(SimpleTestCase):assert f"events.properties.{escaped_property_name}" in expressionassert "toJSONString(events.properties)" not in expression+ rows = sync_execute(+ f"SELECT {expression} FROM (SELECT CAST(arrayJoin(%(documents)s), %(json_type)s) AS properties) AS events",+ {+ "property_key": property_name,+ "json_type": EVENTS_PROPERTIES_JSON_TYPE(),+ "documents": [json.dumps({property_name: value}) for value in [["a", '"b"'], [], None]],+ },+ )+ assert rows == [('["a","\\"b\\""]',), ("",), ("",)]++ def test_jsonextract_string_arrays_read_array_subcolumn(self) -> None:+ printed = self._print_select(+ "select JSONExtract(ifNull(properties.$exception_types, ''), 'Array(String)') from events"+ )++ assert "events.properties.`$exception_types`" in printed, printed+ assert "JSONExtract" not in printed, printed+ assert "toJSONString(events.properties.`$exception_types`)" not in printed, printed+@parameterized.expand([- ("$active_feature_flags", "[]"),- ("$exception_types", ""),+ ("event_direct", "properties.$unparseable_properties", PropertyDefinition.Type.EVENT, False),+ (+ "event_extract",+ "JSONExtractString(properties, '$unparseable_properties')",+ PropertyDefinition.Type.EVENT,+ False,+ ),+ ("event_blob", "properties", PropertyDefinition.Type.EVENT, True),+ ("event_serialized", "toJSONString(properties)", PropertyDefinition.Type.EVENT, True),+ ("person_direct", "poe.properties.$unparseable_properties", PropertyDefinition.Type.PERSON, False),+ (+ "person_extract",+ "JSONExtractString(poe.properties, '$unparseable_properties')",+ PropertyDefinition.Type.PERSON,+ False,+ ),+ ("person_blob", "poe.properties", PropertyDefinition.Type.PERSON, True),])- @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)- def test_jsonextract_string_arrays_read_array_subcolumn(self, property_name: str, default_value: str) -> None:- printed = self._print_select(- f"select JSONExtract(ifNull(properties.{property_name}, '{default_value}'), 'Array(String)') from events"- )+ def test_quarantine_cannot_bypass_property_restrictions(+ self, _name: str, expression: str, property_type: int, blob: bool+ ) -> None:+ context = self._context()+ context.restricted_properties = {RestrictedProperty(name="secret", property_type=property_type)}+ with patch("posthog.hogql.printer.utils.build_property_swapper"):+ printed, _ = prepare_and_print_ast(parse_select(f"SELECT {expression} FROM events"), context, "clickhouse")- assert f"events.properties.`{property_name}`" in printed, printed- assert "JSONExtract" not in printed, printed- assert f"toJSONString(events.properties.`{property_name}`)" not in printed, printed+ if blob:+ assert any(+ isinstance(value, list) and "$unparseable_properties" in value for value in context.values.values()+ ), printed+ else:+ assert "events.properties" not in printed, printed+ assert "events.person_properties" not in printed, printed++ unrestricted = self._print_select(f"SELECT {expression} FROM events")+ assert "JSONDropKeys" not in unrestricted, unrestricted+ assert "events.properties" in unrestricted or "events.person_properties" in unrestricted, unrestricted++ @parameterized.expand(+ [+ ("event", "properties", PropertyDefinition.Type.EVENT),+ ("person", "poe.properties", PropertyDefinition.Type.PERSON),+ ]+ )+ def test_nested_restrictions_mask_parent_and_computed_key_reads(+ self, _name: str, field: str, property_type: int+ ) -> None:+ context = self._context()+ context.restricted_properties = {RestrictedProperty(name="$groups.organization", property_type=property_type)}+ query = parse_select(+ f"""SELECT {field}.$groups,+ {field}.$groups.organization,+ {field}.$groups.project,+ JSONHas({field}, '$groups', 'organization'),+ JSONHas({field}, '$groups', if(event = 'synthetic', 'organization', 'project')),+ JSONHas({field}, '$groups', 'project')+ FROM events"""+ )+ with patch("posthog.hogql.printer.utils.build_property_swapper"):+ printed, _ = prepare_and_print_ast(query, context, "clickhouse")+ [row] = sync_execute(+ """WITH events_json AS (+ SELECT 1 AS team_id, 'synthetic' AS event,+ CAST(%(document)s, %(event_type)s) AS properties,+ CAST(%(document)s, %(person_type)s) AS person_properties+ ) """+ + printed,+ {+ **context.values,+ "document": '{"$groups":{"organization":"hidden","project":"visible"}}',+ "event_type": EVENTS_PROPERTIES_JSON_TYPE(),+ "person_type": PERSON_PROPERTIES_JSON_TYPE(),+ },+ )+ assert row == ('{"project":"visible"}', None, "visible", 0, 0, 1)class TestPropertyTypes(BaseTest):@@ -382,8 +486,8 @@ class TestPropertyTypes(BaseTest):assert plan.access.source.physical_type == ast.StringType(nullable=True)assert plan.physical_compatibility == ComparisonCompatibility.DEFINITELY_COMPATIBLEassert plan.can_compare_physical_source_directly is True- assert plan.can_use_minmax_index is True- assert plan.minmax_blocker is None+ assert plan.can_use_minmax_index is False+ assert plan.minmax_blocker == PropertyMinmaxBlocker.NO_MINMAX_INDEXreturnassert plan.access.source.kind == PropertySourceKind.MATERIALIZED_COLUMN@@ -406,7 +510,7 @@ class TestPropertyTypes(BaseTest):assert plan.physical_compatibility == ComparisonCompatibility.EXPENSIVE_CASTassert plan.can_compare_physical_source_directly is Falseassert plan.can_use_minmax_index is False- assert plan.minmax_blocker == PropertyMinmaxBlocker.SOURCE_TYPE_DIFFERS_FROM_PROPERTY_TYPE+ assert plan.minmax_blocker == PropertyMinmaxBlocker.NO_MINMAX_INDEXreturnassert plan.access.source.kind == PropertySourceKind.MATERIALIZED_COLUMN@@ -441,7 +545,7 @@ class TestPropertyTypes(BaseTest):assert plan.literal_conversion == PropertyLiteralConversion.NONEassert plan.can_compare_physical_source_directly is Falseassert plan.can_use_minmax_index is False- assert plan.minmax_blocker == PropertyMinmaxBlocker.SOURCE_TYPE_DIFFERS_FROM_PROPERTY_TYPE+ assert plan.minmax_blocker == PropertyMinmaxBlocker.NO_MINMAX_INDEXreturnassert plan.access.source.kind == PropertySourceKind.MATERIALIZED_COLUMN@@ -760,11 +864,15 @@ class TestPropertyTypes(BaseTest):])def test_exception_array_property_extracted_for_array_membership_functions(self, fn_name: str, expr: str):- # $exception_* array properties are stored as a raw JSON String once materialized, so passing the+ # Legacy $exception_* array properties are stored as a raw JSON String once materialized, so passing the# bare column to an array function raises ILLEGAL_TYPE_OF_ARGUMENT. It must first be extracted to# Array(String) — the same wrapping property_to_expr applies to typed exception filters.with materialized("events", "$exception_values"):printed = self._print_select(f"select uuid from events where {expr}")+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ assert f"{fn_name}(ifNull(accurateCastOrNull(events.properties.`$exception_values`," in printed+ assert "mat_$exception_values" not in printed+ return# The membership function receives the property extracted to an array, not the bare String column.# (The 'Array(String)' type literal is parameterized out by the printer, so match structure instead.)assert f"{fn_name}(JSONExtract(ifNull(" in printed@@ -945,7 +1053,7 @@ class TestJSONExtractToMaterializedColumn(ClickhouseTestMixin, BaseTest):assert "JSONExtract(ifNull(" in printed, printedassert "JSONExtractString(ifNull(" in printed, printedassert "toJSONString(events.properties)" not in printed, printed- assert "toJSONString(events.properties.^email)" in printed, printed+ assert "toJSONString(events.properties.email)" in printed, printed@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)def test_new_events_schema_nested_jsonextractstring_uses_string_default(self):@@ -971,9 +1079,9 @@ class TestJSONExtractToMaterializedColumn(ClickhouseTestMixin, BaseTest):)assert "events_json" in printed, printed+ assert "JSONExtract(ifNull(" in printed, printedassert "toJSONString(events.properties.arr_field)" in printed, printed- assert "toJSONString(events.properties.^arr_field)" in printed, printed- assert "JSONExtract(events.properties" not in printed, printed+ assert "accurateCastOrNull" not in printed, printed@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)def test_new_events_schema_jsonextract_respects_restricted_properties(self):@@ -1055,7 +1163,7 @@ class TestJSONExtractToMaterializedColumn(ClickhouseTestMixin, BaseTest):team=self.team,distinct_id="array-set",event="jsonextract-array",- properties={"tag": "set", "$active_feature_flags": ["flag"]},+ properties={"tag": "set", "$exception_types": ["TypeError"]},)_create_event(team=self.team,@@ -1066,15 +1174,15 @@ class TestJSONExtractToMaterializedColumn(ClickhouseTestMixin, BaseTest):flush_persons_and_events()response = execute_hogql_query(- "SELECT properties.tag, JSONExtractRaw(properties, '$active_feature_flags') FROM events "+ "SELECT properties.tag, JSONExtractRaw(properties, '$exception_types') FROM events ""WHERE event = 'jsonextract-array' ORDER BY properties.tag",team=self.team,)- assert response.results == [("missing", ""), ("set", '["flag"]')]+ assert response.results == [("missing", ""), ("set", '["TypeError"]')]if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:assert response.clickhouse is not None- assert "events.properties.`$active_feature_flags`" in response.clickhouse+ assert "events.properties.`$exception_types`" in response.clickhouseassert "JSONExtractKeysAndValuesRaw" not in response.clickhousedef _seed_edge_case_events(self):@@ -1197,7 +1305,6 @@ _JSON_SCHEMA_PARITY_PROPERTIES: st.SearchStrategy[dict[str, object]] = st.fixed_)},optional={- "$active_feature_flags": st.lists(_JSON_SCHEMA_PARITY_TEXT, max_size=3),"$browser": st.one_of(st.none(), st.sampled_from(["", "null", "Chrome", "Firefox"])),},)@@ -1210,8 +1317,8 @@ _JSON_SCHEMA_PARITY_PROPERTIES: st.SearchStrategy[dict[str, object]] = st.fixed_class TestEventsSchemaPropertyParity(ClickhouseTestMixin, HypothesisDjangoTestCase, BaseTest):def _query_properties(self, event_uuid: str, use_new_events_schema: bool) -> tuple[Any, ...]:response = execute_hogql_query(- "SELECT properties, properties.dynamic_value, properties.$active_feature_flags, "- "JSONHas(properties, '$active_feature_flags'), properties.$browser, JSONHas(properties, '$browser') "+ "SELECT properties.dynamic_value, properties.$browser, JSONHas(properties, '$browser'), "+ "toJSONString(properties.$browser) "f"FROM events WHERE uuid = '{event_uuid}'",team=self.team,modifiers=HogQLQueryModifiers(materializationMode=MaterializationMode.DISABLED),@@ -1227,8 +1334,9 @@ class TestEventsSchemaPropertyParity(ClickhouseTestMixin, HypothesisDjangoTestCa@given(properties=_JSON_SCHEMA_PARITY_PROPERTIES)@example(properties={"dynamic_value": "value"})- @example(properties={"dynamic_value": "value", "$active_feature_flags": []})- @example(properties={"dynamic_value": "value", "$active_feature_flags": ["flag"]})+ @example(properties={"dynamic_value": "\\"})+ @example(properties={"dynamic_value": '"'})+ @example(properties={"dynamic_value": "é"})@example(properties={"dynamic_value": "value", "$browser": None})@example(properties={"dynamic_value": "value", "$browser": ""})@example(properties={"dynamic_value": "value", "$browser": "null"})@@ -1237,7 +1345,7 @@ class TestEventsSchemaPropertyParity(ClickhouseTestMixin, HypothesisDjangoTestCadeadline=None,suppress_health_check=[HealthCheck.differing_executors],)- def test_property_results_match_except_native_json_storage_defaults(self, properties: dict[str, object]) -> None:+ def test_property_results_match_each_schema_storage_semantics(self, properties: dict[str, object]) -> None:event_uuid = _create_event(team=self.team,distinct_id="schema-parity",@@ -1249,42 +1357,19 @@ class TestEventsSchemaPropertyParity(ClickhouseTestMixin, HypothesisDjangoTestCalegacy = self._query_properties(event_uuid, use_new_events_schema=False)native = self._query_properties(event_uuid, use_new_events_schema=True)- legacy_document = json.loads(legacy[0])- native_document = json.loads(native[0])- # Native JSON cannot preserve JSON nulls, and declared containers use the same default for missing and empty.- expected_native_document = {key: value for key, value in legacy_document.items() if value is not None}- if expected_native_document.get("$active_feature_flags") == []:- del expected_native_document["$active_feature_flags"]-- assert native_document == expected_native_document- assert native[1] == legacy[1]+ value = properties["dynamic_value"]+ encoded = json.dumps(value, ensure_ascii=False)+ assert native[0] == ((value or None) if isinstance(value, str) else encoded)+ assert legacy[0] == (encoded[1:-1] if isinstance(value, str) else encoded)browser = properties.get("$browser")- assert native[4] == legacy[4]-- flags_present = "$active_feature_flags" in properties- flags = properties.get("$active_feature_flags")- if flags_present and flags == []:- assert legacy[2:4] == ("[]", True)- assert native[2:4] == (None, False)- else:- assert native[2:4] == legacy[2:4]+ assert native[1] == (browser or None)+ assert native[3] == (json.dumps(browser) if browser else None)- if "$browser" in properties and browser is None:- assert legacy[5] == 1- assert native[5] == 0+ if browser in (None, ""):+ assert native[2] == 0else:- assert native[5] == legacy[5]-- raw_native_document = json.loads(- sync_execute(- f"SELECT toJSONString(properties) FROM {DISTRIBUTED_EVENTS_JSON_TABLE} WHERE uuid = %(uuid)s",- {"uuid": event_uuid},- )[0][0]- )- # Typed paths physically exist with defaults even when the captured document omitted them.- assert raw_native_document["$active_feature_flags"] == properties.get("$active_feature_flags", [])- assert raw_native_document["$browser"] == properties.get("$browser")+ assert native[2] == legacy[2]# ── Timezone index pruning tests ──────────────────────────────────────────────@@ -1333,7 +1418,7 @@ class TestTimezoneIndexPruning(ClickhouseTestMixin, BaseTest):def _assert_primary_key_uses_timestamp_range(self, primary_key: dict) -> None:pk_keys = primary_key.get("Keys", [])- expected_timestamp_key = "timestamp" if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else "toDate(timestamp)"+ expected_timestamp_key = "toDate(timestamp)"assert any(expected_timestamp_key in key for key in pk_keys), (f"Expected PK to use {expected_timestamp_key}, got Keys={pk_keys}")@@ -1363,11 +1448,10 @@ class TestTimezoneIndexPruning(ClickhouseTestMixin, BaseTest):)indexes = get_indexes_from_explain(sql)- partition = _get_index_by_type(indexes, "Partition")- assert partition is not None- assert partition.get("Condition") != "true", (- f"Partition pruning should work with bare timestamp, got Condition={partition.get('Condition')!r}"- )+ pruning_index = _get_index_by_type(indexes, "Min-Max")+ assert pruning_index is not None+ assert pruning_index["Condition"] != "true"+ assert pruning_index["Selected Parts"] < pruning_index["Initial Parts"], pruning_indexprimary_key = _get_index_by_type(indexes, "PrimaryKey")assert primary_key is not None@@ -1407,11 +1491,10 @@ class TestTimezoneIndexPruning(ClickhouseTestMixin, BaseTest):)indexes = get_indexes_from_explain(sql, values)- partition = _get_index_by_type(indexes, "Partition")- assert partition is not None- assert partition.get("Condition") != "true", (- f"Expected partition pruning. Partition Condition={partition.get('Condition')!r}"- )+ pruning_index = _get_index_by_type(indexes, "Min-Max")+ assert pruning_index is not None+ assert pruning_index["Condition"] != "true"+ assert pruning_index["Selected Parts"] < pruning_index["Initial Parts"], pruning_indexprimary_key = _get_index_by_type(indexes, "PrimaryKey")assert primary_key is not Nonediff --git a/posthog/hogql_queries/ai/ai_column_rewriter.py b/posthog/hogql_queries/ai/ai_column_rewriter.pyindex 67724f79beef..4678c3cff2cf 100644--- a/posthog/hogql_queries/ai/ai_column_rewriter.py+++ b/posthog/hogql_queries/ai/ai_column_rewriter.py@@ -16,7 +16,7 @@ The rewriter is scope-aware: it only rewrites fields within SELECT queries that"""from posthog.hogql import ast-from posthog.hogql.visitor import CloningVisitor+from posthog.hogql.visitor import CloningVisitor, clone_exprfrom posthog.hogql_queries.ai.ai_property_rewriter import AI_PROPERTY_TO_COLUMN@@ -145,6 +145,9 @@ class AiColumnToPropertyRewriter(CloningVisitor):return super().visit_field(node)+ def visit_placeholder(self, node: ast.Placeholder) -> ast.Placeholder:+ return clone_expr(node)+def visit_join_expr(self, node: ast.JoinExpr) -> ast.JoinExpr:new_node = super().visit_join_expr(node)# Swap FROM posthog.ai_events -> FROM events (also handle aliased form).diff --git a/posthog/hogql_queries/ai/event_taxonomy_query_runner.py b/posthog/hogql_queries/ai/event_taxonomy_query_runner.pyindex 840a15896ae3..e4cc9e98f36e 100644--- a/posthog/hogql_queries/ai/event_taxonomy_query_runner.py+++ b/posthog/hogql_queries/ai/event_taxonomy_query_runner.py@@ -110,6 +110,7 @@ class EventTaxonomyQueryRunner(TaxonomyCacheMixin, AnalyticsQueryRunner[EventTaxr"\$ip",# feature flags and experimentsr"\$feature\/",+ r"^\$feature_flags$",r"\$feature_enrollment\/",r"\$feature_interaction\/",# product toursdiff --git a/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.ambr b/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.ambrindex 8820b809780e..3ea5419b2c03 100644--- a/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.ambr+++ b/posthog/hogql_queries/ai/test/__snapshots__/test_event_taxonomy_query_runner.ambr@@ -19,7 +19,7 @@LIMIT 100) ARRAYJOIN (kv).1 AS key,(kv).2 AS value- WHERE and(not(match(key, '(\\$set|\\$time|\\$set_once|\\$sent_at|distinct_id|\\$ip|\\$feature\\/|\\$feature_enrollment\\/|\\$feature_interaction\\/|\\$product_tour|__|survey_dismiss|survey_responded|phjs|partial_filter_chosen|changed_action|window-id|changed_event|partial_filter)')), isNotNull(value), ifNull(notEquals(value, ''), 1))+ WHERE and(not(match(key, '(\\$set|\\$time|\\$set_once|\\$sent_at|distinct_id|\\$ip|\\$feature\\/|^\\$feature_flags$|\\$feature_enrollment\\/|\\$feature_interaction\\/|\\$product_tour|__|survey_dismiss|survey_responded|phjs|partial_filter_chosen|changed_action|window-id|changed_event|partial_filter)')), isNotNull(value), ifNull(notEquals(value, ''), 1))GROUP BY key,value)GROUP BY key@@ -99,7 +99,7 @@LIMIT 100) ARRAYJOIN (kv).1 AS key,(kv).2 AS value- WHERE and(not(match(key, '(\\$set|\\$time|\\$set_once|\\$sent_at|distinct_id|\\$ip|\\$feature\\/|\\$feature_enrollment\\/|\\$feature_interaction\\/|\\$product_tour|__|survey_dismiss|survey_responded|phjs|partial_filter_chosen|changed_action|window-id|changed_event|partial_filter)')), isNotNull(value), ifNull(notEquals(value, ''), 1))+ WHERE and(not(match(key, '(\\$set|\\$time|\\$set_once|\\$sent_at|distinct_id|\\$ip|\\$feature\\/|^\\$feature_flags$|\\$feature_enrollment\\/|\\$feature_interaction\\/|\\$product_tour|__|survey_dismiss|survey_responded|phjs|partial_filter_chosen|changed_action|window-id|changed_event|partial_filter)')), isNotNull(value), ifNull(notEquals(value, ''), 1))GROUP BY key,value)GROUP BY keydiff --git a/posthog/hogql_queries/ai/test/test_ai_column_rewriter.py b/posthog/hogql_queries/ai/test/test_ai_column_rewriter.pyindex f148ea6eba3c..545503d8e3ce 100644--- a/posthog/hogql_queries/ai/test/test_ai_column_rewriter.py+++ b/posthog/hogql_queries/ai/test/test_ai_column_rewriter.py@@ -2,6 +2,7 @@ import pytestfrom posthog.hogql import astfrom posthog.hogql.parser import parse_select+from posthog.hogql.placeholders import replace_placeholdersfrom posthog.hogql_queries.ai.ai_column_rewriter import (_BOOLEAN_COLUMNS,@@ -116,8 +117,10 @@ class TestAiColumnToPropertyRewriter:assert isinstance(result, ast.Field), f"{col_name} should not be wrapped"def test_scope_only_rewrites_in_ai_events_query(self):- query = parse_select("SELECT trace_id FROM posthog.ai_events AS ai_events")- result = rewrite_query_for_events_table(query)+ query = parse_select("SELECT trace_id FROM posthog.ai_events AS ai_events WHERE trace_id = {trace_id}")+ result = replace_placeholders(+ rewrite_query_for_events_table(query), {"trace_id": ast.Constant(value="trace-1")}+ )assert isinstance(result, ast.SelectQuery)# Rewritten select item is re-aliased to its original column name so the# query's output schema stays stable for downstream consumers.@@ -130,6 +133,9 @@ class TestAiColumnToPropertyRewriter:assert isinstance(result.select_from.table, ast.Field)assert result.select_from.table.chain == ["events"]assert result.select_from.alias == _EVENTS_TABLE_ALIAS+ assert isinstance(result.where, ast.CompareOperation)+ assert isinstance(result.where.right, ast.Constant)+ assert result.where.right.value == "trace-1"def test_scope_skips_non_ai_events_query(self):query = parse_select("SELECT trace_id FROM events")diff --git a/posthog/hogql_queries/ai/test/test_event_taxonomy_query_runner.py b/posthog/hogql_queries/ai/test/test_event_taxonomy_query_runner.pyindex 46592a247618..9754b9a28dc3 100644--- a/posthog/hogql_queries/ai/test/test_event_taxonomy_query_runner.py+++ b/posthog/hogql_queries/ai/test/test_event_taxonomy_query_runner.py@@ -493,7 +493,7 @@ class TestEventTaxonomyQueryRunner(ClickhouseTestMixin, APIBaseTest):_create_event(event="event1",distinct_id="person2",- properties={"prop": "3", "$feature/dashboard": "0"},+ properties={"prop": "3", "$feature/dashboard": "0", "$feature_flags": {"another_flag": "true"}},team=self.team,)@@ -555,7 +555,7 @@ class TestEventTaxonomyQueryRunner(ClickhouseTestMixin, APIBaseTest):_create_event(event="event",distinct_id="person1",- properties={"prop": "3", "$feature/dashboard": "0"},+ properties={"prop": "3", "$feature/dashboard": "0", "$feature_flags": {"another_flag": "true"}},team=self.team,)diff --git a/posthog/hogql_queries/ai/test/test_session_query_runner.py b/posthog/hogql_queries/ai/test/test_session_query_runner.pyindex af389f22b64f..af02b27dd2d8 100644--- a/posthog/hogql_queries/ai/test/test_session_query_runner.py+++ b/posthog/hogql_queries/ai/test/test_session_query_runner.py@@ -3,6 +3,8 @@ from typing import Anyfrom posthog.test.base import BaseTest, ClickhouseTestMixin+from django.conf import settings+from parameterized import parameterizedfrom posthog.schema import DateRange, SessionQuery@@ -425,7 +427,10 @@ class TestSessionQueryRunner(ClickhouseTestMixin, BaseTest):trace = response.results[0]self.assertEqual(trace.id, "trace-date-from")self.assertEqual(trace.aiSessionId, "session-date-from")- self.assertEqual(trace.events[0].properties["$ai_output_choices"][0]["content"], "hi")+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ self.assertNotIn("$ai_output_choices", trace.events[0].properties)+ else:+ self.assertEqual(trace.events[0].properties["$ai_output_choices"][0]["content"], "hi")self.assertEqual(trace.inputTokens, 5)self.assertEqual(trace.outputTokens, 2)self.assertAlmostEqual(trace.totalCost or 0, 0.01)diff --git a/posthog/hogql_queries/ai/test/test_traces_query_runner.py b/posthog/hogql_queries/ai/test/test_traces_query_runner.pyindex d152bcffbbce..956459fe37e9 100644--- a/posthog/hogql_queries/ai/test/test_traces_query_runner.py+++ b/posthog/hogql_queries/ai/test/test_traces_query_runner.py@@ -8,6 +8,8 @@ import time_machinefrom posthog.test.base import BaseTest, ClickhouseTestMixin, _create_event, _create_person, snapshot_clickhouse_queriesfrom unittest.mock import patch+from django.conf import settings+from parameterized import parameterizedfrom posthog.schema import (@@ -1113,34 +1115,47 @@ class TestTracesQueryRunner(ClickhouseTestMixin, BaseTest):self.assertEqual(len(response.results[0].events), 1)self.assertEqual(response.results[0].events[0].properties["$ai_model_parameters"], {"temperature": 0.5})- def test_property_filter_matches_an_explicit_empty_string(self):+ @parameterized.expand(["$ai_span_name", "custom_span_name"])+ def test_property_filter_matches_an_explicit_empty_string(self, property_name: str):_create_person(distinct_ids=["person1"], team=self.team)_create_ai_generation_event(distinct_id="person1",trace_id="trace_with_empty_name",team=self.team,timestamp=datetime(2024, 12, 1, 0, 0),- properties={"$ai_span_name": ""},+ properties={property_name: ""},)_create_ai_generation_event(distinct_id="person1",trace_id="trace_with_name",team=self.team,timestamp=datetime(2024, 12, 1, 0, 0),- properties={"$ai_span_name": "chat"},+ properties={property_name: "chat"},+ )++ _create_ai_generation_event(+ distinct_id="person1",+ trace_id="trace_without_name",+ team=self.team,+ timestamp=datetime(2024, 12, 1, 0, 0),)response = TracesQueryRunner(team=self.team,query=TracesQuery(properties=[- EventPropertyFilter(key="$ai_span_name", value=[""], operator=PropertyOperator.EXACT),+ EventPropertyFilter(key=property_name, value=[""], operator=PropertyOperator.EXACT),],dateRange=DateRange(date_from="2024-12-01T00:00:00Z", date_to="2024-12-01T00:10:00Z"),),).calculate()- self.assertEqual({result.id for result in response.results}, {"trace_with_empty_name"})+ expected_ids = (+ set()+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA and property_name == "$ai_span_name"+ else {"trace_with_empty_name"}+ )+ self.assertEqual({result.id for result in response.results}, expected_ids)@snapshot_clickhouse_queriesdef test_properties_filter_with_multiple_events_in_group(self):diff --git a/posthog/hogql_queries/test/test_events_query_runner.py b/posthog/hogql_queries/test/test_events_query_runner.pyindex 8820e37987f8..0565ad2adcee 100644--- a/posthog/hogql_queries/test/test_events_query_runner.py+++ b/posthog/hogql_queries/test/test_events_query_runner.py@@ -12,6 +12,8 @@ from posthog.test.base import (snapshot_clickhouse_queries,)+from django.conf import settings+from parameterized import parameterizedfrom posthog.schema import (@@ -163,7 +165,11 @@ class TestEventsQueryRunner(ClickhouseTestMixin, APIBaseTest):# String session id is checked for a recording (none exists, so False); non-string ones are skipped.assert by_distinct_id["good"]["$has_recording"] is Falsefor distinct_id in ("dict", "list", "int"):- assert "$has_recording" not in by_distinct_id[distinct_id]+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ assert isinstance(by_distinct_id[distinct_id]["$session_id"], str)+ assert by_distinct_id[distinct_id]["$has_recording"] is False+ else:+ assert "$has_recording" not in by_distinct_id[distinct_id]def test_person_id_expands_to_distinct_ids(self):_create_person(diff --git a/posthog/models/deletion_targets.py b/posthog/models/deletion_targets.pyindex a491f12c54bb..1173865cd109 100644--- a/posthog/models/deletion_targets.py+++ b/posthog/models/deletion_targets.py@@ -180,7 +180,6 @@ EVENTS_JSON = DeletionTarget(cluster_setting="CLICKHOUSE_EVENTS_CLUSTER",node_role=NodeRole.EVENTS,hogql_schema=HogQLSchema.NATIVE_JSON,- accepts_property_rewrite=True,# Dual-written from the same events, so its uuids are the legacy table's.queue_uuid_candidates=False,)diff --git a/posthog/models/event/sql.py b/posthog/models/event/sql.pyindex aff6c142fe09..f3384e3fbece 100644--- a/posthog/models/event/sql.py+++ b/posthog/models/event/sql.py@@ -1,6 +1,7 @@from django.conf import settingsfrom posthog.hogql.escape_sql import escape_clickhouse_identifier, escape_clickhouse_string+from posthog.hogql.functions.udfs import JSON_STRIP_EMPTY_STRINGS_AND_NULLS_CLICKHOUSE_NAMEfrom posthog.clickhouse.base_sql import COPY_ROWS_BETWEEN_TEAMS_BASE_SQLfrom posthog.clickhouse.cluster import ON_CLUSTER_CLAUSE@@ -16,8 +17,8 @@ from posthog.clickhouse.events_json import (EVENTS_PROPERTIES_JSON_SUBCOLUMNS,KAFKA_EVENTS_NATIVE_JSON_TABLE,PERSON_PROPERTIES_JSON_SUBCOLUMNS,+ UNPARSEABLE_PROPERTIES_KEY,WRITABLE_EVENTS_JSON_TABLE,- _json_subcolumn_type_supports_nullable,)from posthog.clickhouse.indexes import index_by_kafka_timestampfrom posthog.clickhouse.kafka_engine import (@@ -42,49 +43,62 @@ def WRITABLE_EVENTS_DATA_TABLE():return "writable_events"-def _json_column_type(max_dynamic_types: int, max_dynamic_paths: int, subcolumns: dict[str, str]) -> str:+def _json_column_type(subcolumns: dict[str, str]) -> str:explicit_paths = ", ".join(f"{escape_clickhouse_identifier(name)} {column_type}" for name, column_type in subcolumns.items())- return f"JSON(max_dynamic_types = {max_dynamic_types}, max_dynamic_paths = {max_dynamic_paths}, {explicit_paths})"+ return f"JSON(max_dynamic_paths = 0, {explicit_paths})"def EVENTS_PROPERTIES_JSON_TYPE() -> str:- return _json_column_type(8, 256, EVENTS_PROPERTIES_JSON_SUBCOLUMNS)+ return _json_column_type(EVENTS_PROPERTIES_JSON_SUBCOLUMNS)def PERSON_PROPERTIES_JSON_TYPE() -> str:- return _json_column_type(6, 32, PERSON_PROPERTIES_JSON_SUBCOLUMNS)+ return _json_column_type(PERSON_PROPERTIES_JSON_SUBCOLUMNS)def json_property_presence_expr(column: str, prop: str) -> str:"""SQL predicate testing whether a (possibly dotted) property path is present in a native-JSONevents column, for deletion/mutation predicates that run against the JSON events tables.- Mirrors the HogQL resolver's JSONHas lowering: a typed subcolumn is present when non-null; a- dynamic path is present when its scalar read is non-null or its sub-object read is non-empty.+ Mirrors the HogQL resolver's JSONHas lowering, with the materialized-column rule that an empty+ value is absent: a declared path is present when it is not null and not empty; a dynamic path+ is present when its scalar read is a non-empty string or its sub-object holds a non-empty value.ClickHouse's JSONHas() cannot be used directly on a JSON-typed column — it does not see typedpaths or nested objects there."""- if column not in ("properties", "person_properties"):+ if column not in ("properties", "person_properties", "temporary_properties"):raise ValueError(f"unsupported JSON events column: {column}")- subcolumns = EVENTS_PROPERTIES_JSON_SUBCOLUMNS if column == "properties" else PERSON_PROPERTIES_JSON_SUBCOLUMNS+ subcolumns = {+ "properties": EVENTS_PROPERTIES_JSON_SUBCOLUMNS,+ "person_properties": PERSON_PROPERTIES_JSON_SUBCOLUMNS,+ "temporary_properties": {},+ }[column]+ if column == "properties" and prop.startswith("$feature/"):+ key = escape_clickhouse_string(prop.removeprefix("$feature/"))+ return f"mapContains(properties.`$feature_flags`, {key})"parts = prop.split(".")column_sql = escape_clickhouse_identifier(column)path_sql = ".".join(escape_clickhouse_identifier(part) for part in parts)scalar = f"{column_sql}.{path_sql}"- if len(parts) == 1 and prop in subcolumns:- if not _json_subcolumn_type_supports_nullable(subcolumns[prop]):- # Native container paths use the empty value for both missing and explicitly empty values.+ # Declared paths can be dotted ($groups.organization), so match the whole path before the head.+ if prop in subcolumns:+ if not subcolumns[prop].startswith("Nullable("):return f"notEmpty({scalar})"return f"isNotNull({scalar})"- if parts[0] in subcolumns:+ if len(parts) > 1 and parts[0] in subcolumns:head = f"{column_sql}.{escape_clickhouse_identifier(parts[0])}"head_document = head if subcolumns[parts[0]] in ("String", "Nullable(String)") else f"toJSONString({head})"tail = ", ".join(escape_clickhouse_string(part) for part in parts[1:])return f"JSONHas(ifNull({head_document}, ''), {tail})"+ # The sub-object serializes the '' default of every declared path under it ($groups always+ # shows organization/project/instance), so strip empty values before the emptiness check.sub_object = f"{column_sql}.^{path_sql}"- return f"(isNotNull({scalar}) OR toJSONString({sub_object}) != '{{}}')"+ return (+ f"(notEmpty(ifNull(toString({scalar}), '')) "+ f"OR {JSON_STRIP_EMPTY_STRINGS_AND_NULLS_CLICKHOUSE_NAME}(toJSONString({sub_object})) != '{{}}')"+ )def TRUNCATE_EVENTS_TABLE_SQL():@@ -217,7 +231,7 @@ def _json_subcolumn(column: str, path: str) -> str:return f"{escape_clickhouse_identifier(column)}.{escape_clickhouse_identifier(path)}"-EVENTS_JSON_DATA_COMPATIBILITY_COLUMNS = f"""+EVENTS_JSON_PROXY_COMPATIBILITY_COLUMNS = f""", $group_0 String ALIAS ifNull({_json_subcolumn("properties", "$group_0")}, ''), $group_1 String ALIAS ifNull({_json_subcolumn("properties", "$group_1")}, ''), $group_2 String ALIAS ifNull({_json_subcolumn("properties", "$group_2")}, '')@@ -226,63 +240,52 @@ EVENTS_JSON_DATA_COMPATIBILITY_COLUMNS = f""", $window_id String ALIAS ifNull({_json_subcolumn("properties", "$window_id")}, ''), $session_id String ALIAS ifNull({_json_subcolumn("properties", "$session_id")}, ''), $session_id_uuid Nullable(UInt128) ALIAS toUInt128(toUUIDOrNull({_json_subcolumn("properties", "$session_id")}))+"""++EVENTS_JSON_ELEMENTS_COLUMNS = """, elements_chain_href String MATERIALIZED extract(elements_chain, '(?::|\")href="(.*?)"'), elements_chain_texts Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|\")text="(.*?)"')), elements_chain_ids Array(String) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?::|\")attr_id="(.*?)"')), elements_chain_elements Array(Enum('a', 'button', 'form', 'input', 'select', 'textarea', 'label')) MATERIALIZED arrayDistinct(extractAll(elements_chain, '(?:^|;)(a|button|form|input|select|textarea|label)(?:\\.|$|:)'))"""--EVENTS_JSON_PROXY_COMPATIBILITY_COLUMNS = """- , $group_0 String- , $group_1 String- , $group_2 String- , $group_3 String- , $group_4 String- , $window_id String- , $session_id String- , $session_id_uuid Nullable(UInt128)- , elements_chain_href String- , elements_chain_texts Array(String)- , elements_chain_ids Array(String)- , elements_chain_elements Array(Enum('a', 'button', 'form', 'input', 'select', 'textarea', 'label'))-"""--EVENTS_JSON_TABLE_BASE_SQL = """CREATE TABLE IF NOT EXISTS {table_name} {on_cluster_clause}(uuid UUID,event String,properties {properties_json_type},- timestamp DateTime64(6, 'UTC'),+ temporary_properties JSON(max_dynamic_paths = 32){temporary_properties_storage},+ timestamp DateTime64(6, 'UTC'){gcd_codec},team_id Int64,distinct_id String,- elements_hash String DEFAULT '',- created_at DateTime64(6, 'UTC'),- _timestamp DateTime,- _offset UInt64,+ created_at DateTime64(6, 'UTC') DEFAULT now(){gcd_codec},+ _timestamp DateTime{t64_codec},+ _offset UInt64{t64_codec},elements_chain String,person_id UUID,person_properties {person_properties_json_type},- group0_properties String CODEC(ZSTD(3)),- group1_properties String CODEC(ZSTD(3)),- group2_properties String CODEC(ZSTD(3)),- group3_properties String CODEC(ZSTD(3)),- group4_properties String CODEC(ZSTD(3)),- person_created_at DateTime64(3),+ group0_properties String,+ group1_properties String,+ group2_properties String,+ group3_properties String,+ group4_properties String,+ person_created_at DateTime64(3){gcd_codec},group0_created_at DateTime64(3),group1_created_at DateTime64(3),group2_created_at DateTime64(3),group3_created_at DateTime64(3),group4_created_at DateTime64(3),- inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ inserted_at DateTime64(6, 'UTC') DEFAULT now64(){gcd_codec},person_mode Enum8('full' = 0, 'propertyless' = 1, 'force_upgrade' = 2),- is_deleted Bool DEFAULT false,consumer_breadcrumbs Array(String),- historical_migration Bool DEFAULT false- {compatibility_columns}- {indexes}+ historical_migration Bool,+ total_event_size UInt32{t64_codec},+ captured_at DateTime64(6, 'UTC') DEFAULT now(){gcd_codec},+ _partition UInt64{t64_codec}+{elements_columns}+{compatibility_columns}+{indexes}) ENGINE = {engine}"""@@ -290,11 +293,11 @@ CREATE TABLE IF NOT EXISTS {table_name} {on_cluster_clause}def EVENTS_JSON_TABLE_SQL(on_cluster: bool = False) -> str:return (EVENTS_JSON_TABLE_BASE_SQL- + """PARTITION BY toYYYYMM(timestamp)-PRIMARY KEY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id))-ORDER BY (team_id, toDate(timestamp), event, timestamp, cityHash64(distinct_id), distinct_id, uuid)+ + """PARTITION BY clamp(toYYYYMM(timestamp), 202001, 203512)+PRIMARY KEY (team_id, toDate(timestamp), event, cityHash64(distinct_id))+ORDER BY (team_id, toDate(timestamp), event, cityHash64(distinct_id), timestamp, uuid)SAMPLE BY cityHash64(distinct_id)-SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', object_shared_data_serialization_version_for_zero_level_parts = 'map', merge_max_block_size = 131072, merge_max_block_size_bytes = 67108864, vertical_merge_algorithm_min_rows_to_activate = 0+SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', enable_block_offset_column = 1, enable_block_number_column = 1, map_serialization_version = 'with_buckets', string_serialization_version = 'single_stream', propagate_types_serialization_versions_to_nested_types = 1""").format(table_name=EVENTS_JSON_DATA_TABLE,@@ -302,7 +305,11 @@ SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_sengine=EVENTS_JSON_DATA_TABLE_ENGINE(),properties_json_type=EVENTS_PROPERTIES_JSON_TYPE(),person_properties_json_type=PERSON_PROPERTIES_JSON_TYPE(),- compatibility_columns=EVENTS_JSON_DATA_COMPATIBILITY_COLUMNS,+ temporary_properties_storage=" TTL toDateTime(inserted_at) + INTERVAL 60 DAY",+ gcd_codec=" CODEC(GCD, Default)",+ t64_codec=" CODEC(T64, Default)",+ elements_columns=EVENTS_JSON_ELEMENTS_COLUMNS,+ compatibility_columns="",indexes=EVENTS_JSON_DATA_TABLE_INDEXES(),)@@ -314,6 +321,10 @@ def WRITABLE_EVENTS_JSON_TABLE_SQL(on_cluster: bool = False) -> str:engine=Distributed(data_table=EVENTS_JSON_DATA_TABLE, sharding_key="sipHash64(distinct_id)"),properties_json_type=EVENTS_PROPERTIES_JSON_TYPE(),person_properties_json_type=PERSON_PROPERTIES_JSON_TYPE(),+ temporary_properties_storage="",+ gcd_codec="",+ t64_codec="",+ elements_columns="",compatibility_columns="",indexes="",)@@ -326,7 +337,17 @@ def DISTRIBUTED_EVENTS_JSON_TABLE_SQL(on_cluster: bool = False) -> str:engine=Distributed(data_table=EVENTS_JSON_DATA_TABLE, sharding_key="sipHash64(distinct_id)"),properties_json_type=EVENTS_PROPERTIES_JSON_TYPE(),person_properties_json_type=PERSON_PROPERTIES_JSON_TYPE(),- compatibility_columns=EVENTS_JSON_PROXY_COMPATIBILITY_COLUMNS,+ temporary_properties_storage="",+ gcd_codec="",+ t64_codec="",+ elements_columns="",+ compatibility_columns=EVENTS_JSON_PROXY_COMPATIBILITY_COLUMNS+ + """+ , elements_chain_href String+ , elements_chain_texts Array(String)+ , elements_chain_ids Array(String)+ , elements_chain_elements Array(Enum('a', 'button', 'form', 'input', 'select', 'textarea', 'label'))+""",indexes="",)@@ -399,7 +420,7 @@ def KAFKA_EVENTS_NATIVE_JSON_TABLE_SQL(on_cluster: bool = False) -> str:table_name=KAFKA_EVENTS_NATIVE_JSON_TABLE,on_cluster_clause=ON_CLUSTER_CLAUSE(on_cluster),engine=kafka_engine(topic=KAFKA_EVENTS_JSON, group=CONSUMER_GROUP_EVENTS_JSON_NATIVE_JSON),- extra_fields="",+ extra_fields=", captured_at Nullable(DateTime64(6, 'UTC'))",dynamically_materialized_columns=EVENTS_TABLE_DYNAMICALLY_MATERIALIZED_COLUMNS(),materialized_columns="",indexes="",@@ -474,27 +495,13 @@ FROM {database}.{kafka_table})-def _poison_safe_json_cast(column: str, fallback_key: str) -> str:- """Cast a String properties payload to the JSON column type without ever throwing.+def _clean_properties(column: str, cleaner: str, json_type: str) -> str:+ fallback = f"concat('{{\"{UNPARSEABLE_PROPERTIES_KEY}\":', toJSONString({column}), '}}')"+ cleaned = f"if(isValidJSON({column}) AND startsWith(trimLeft({column}), '{{'), {cleaner}({column}), {fallback})"+ escaped_type = escape_clickhouse_string(json_type)+ return f"ifNull(accurateCastOrNull({cleaned}, {escaped_type}), CAST({fallback}, {escaped_type}))"- The JSON type's parser rejects some payloads that are valid JSON — notably integers outside- [-2^63, 2^64) fail with INCORRECT_DATA. A throwing cast inside a Kafka materialized view is a- poison message: kafka_skip_broken_messages only covers format parsing, so the consumer would- retry the same block forever and stall ingestion for the whole table. Unparseable payloads are- instead preserved verbatim under a single string property so they can be repaired later.- """- return (- f"ifNull(accurateCastOrNull({column}, 'JSON'), "- f"CAST(concat('{{\"{fallback_key}\":', toJSONString({column}), '}}'), 'JSON')) AS {column}"- )--# Dual-write materialized view that writes events into the native-JSON schema-# (writable_events_json). It reads from a dedicated Kafka consumer group so JSON-table retries do not-# replay legacy writes through events_json_mv. The string properties/person_properties payloads are-# cast to the destination JSON columns via a poison-safe cast (see _poison_safe_json_cast). Unlike the-# legacy MV this does not project the dmat_string_* columns — they don't exist on the JSON table,-# whose property reads come from JSON subcolumns instead.def EVENTS_JSON_TABLE_MV_SQL(mv_name="events_json_table_mv",kafka_table=KAFKA_EVENTS_NATIVE_JSON_TABLE,@@ -507,18 +514,26 @@ def EVENTS_JSON_TABLE_MV_SQL(return """CREATE MATERIALIZED VIEW IF NOT EXISTS {mv_name} {on_cluster_clause}TO {database}.{target_table}-AS SELECT+AS+SELECT+*,+accurateCast(byteSize(*) + byteSize(toUInt32(0)), 'UInt32') AS total_event_size+FROM+(+SELECTuuid,event,-{properties_expr},+{properties_expr} AS properties,+JSONCleanPostHogTemporaryProperties(if(isValidJSON(source.properties) AND startsWith(trimLeft(source.properties), '{{'), source.properties, '{{}}')) AS temporary_properties,+now64() AS inserted_at,timestamp,team_id,distinct_id,elements_chain,created_at,person_id,+{person_properties_expr} AS person_properties,person_created_at,-{person_properties_expr},group0_properties,group1_properties,group2_properties,@@ -531,8 +546,10 @@ group3_created_at,group4_created_at,person_mode,historical_migration,+coalesce(captured_at, created_at) AS captured_at,_timestamp,_offset,+_partition,arrayMap(i -> _headers.value[i],arrayFilter(@@ -540,15 +557,20 @@ arrayMap(arrayEnumerate(_headers.name))) as consumer_breadcrumbs-FROM {database}.{kafka_table}+FROM {database}.{kafka_table} AS source+)""".format(mv_name=mv_name,kafka_table=kafka_table,target_table=target_table,on_cluster_clause=f"ON CLUSTER '{settings.CLICKHOUSE_CLUSTER}'" if on_cluster else "",database=settings.CLICKHOUSE_DATABASE,- properties_expr=_poison_safe_json_cast("properties", "$unparseable_properties"),- person_properties_expr=_poison_safe_json_cast("person_properties", "$unparseable_properties"),+ properties_expr=_clean_properties(+ "source.properties", "JSONCleanPostHogEventProperties", EVENTS_PROPERTIES_JSON_TYPE()+ ),+ person_properties_expr=_clean_properties(+ "source.person_properties", "JSONCleanPostHogPersonProperties", PERSON_PROPERTIES_JSON_TYPE()+ ),)@@ -756,10 +778,17 @@ def DISTRIBUTED_EVENTS_TABLE_SQL(on_cluster=True):)-def INSERT_EVENT_SQL(table_name: str | None = None) -> str:+def BULK_INSERT_EVENT_SQL(table_name: str | None = None, *, values: str = "") -> str:if table_name is None:table_name = EVENTS_DATA_TABLE()+ # Native fixtures need ingestion cleanup, and VALUES cannot execute an external UDF.+ source = (+ f"SELECT * REPLACE(JSONCleanPostHogEventProperties(source.c3) AS c3), "+ f"JSONCleanPostHogTemporaryProperties(source.c3) FROM values({values}) AS source"+ if table_name == EVENTS_JSON_DATA_TABLE+ else f"VALUES{values}"+ )return f"""INSERT INTO {table_name}(@@ -786,9 +815,16 @@ INSERT INTO {table_name}person_mode,created_at,_timestamp,- _offset+ _offset{", temporary_properties" if table_name == EVENTS_JSON_DATA_TABLE else ""})-VALUES+{source}+"""+++def INSERT_EVENT_SQL(table_name: str | None = None) -> str:+ return BULK_INSERT_EVENT_SQL(+ table_name,+ values="""(%(uuid)s,%(event)s,@@ -814,44 +850,8 @@ VALUES%(created_at)s,now(),0-)-"""---def BULK_INSERT_EVENT_SQL(table_name: str | None = None) -> str:- if table_name is None:- table_name = EVENTS_DATA_TABLE()-- return f"""-INSERT INTO {table_name}-(- uuid,- event,- properties,- timestamp,- team_id,- distinct_id,- elements_chain,- person_id,- person_properties,- person_created_at,- group0_properties,- group1_properties,- group2_properties,- group3_properties,- group4_properties,- group0_created_at,- group1_created_at,- group2_created_at,- group3_created_at,- group4_created_at,- person_mode,- created_at,- _timestamp,- _offset-)-VALUES-"""+)""",+ )NULL_SQL = """diff --git a/posthog/models/event/util.py b/posthog/models/event/util.pyindex ffc235a371a0..9135e8e9eb65 100644--- a/posthog/models/event/util.py+++ b/posthog/models/event/util.py@@ -320,7 +320,9 @@ def bulk_create_events(}if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:sync_execute(- BULK_INSERT_EVENT_SQL(table_name=EVENTS_JSON_DATA_TABLE) + ", ".join(inserts), json_params, flush=False+ BULK_INSERT_EVENT_SQL(table_name=EVENTS_JSON_DATA_TABLE, values=", ".join(inserts)),+ json_params,+ flush=False,)sync_execute(BULK_INSERT_EVENT_SQL() + ", ".join(inserts), params, flush=False)diff --git a/posthog/models/property/util.py b/posthog/models/property/util.pyindex 8654b193ce1b..a469541db364 100644--- a/posthog/models/property/util.py+++ b/posthog/models/property/util.py@@ -15,7 +15,6 @@ from posthog.hogql.visitor import TraversingVisitorfrom posthog.clickhouse.kafka_engine import trim_quotes_exprfrom posthog.clickhouse.materialized_columns import TableWithProperties, get_materialized_column_for_propertyfrom posthog.models.event import Selector-from posthog.models.event.sql import EVENTS_PROPERTIES_JSON_SUBCOLUMNS, PERSON_PROPERTIES_JSON_SUBCOLUMNSfrom posthog.models.property import Property, PropertyGroup, PropertyIdentifier, PropertyNamefrom products.actions.backend.models.action import Action@@ -54,7 +53,7 @@ def get_property_string_expr(if use_new_events_schema and table == "events":if materialised_table_column in ("properties", "person_properties"):- return _json_events_property_expr(property_name, var, f"{table_string}{column}", materialised_table_column)+ return _json_events_property_expr(property_name, var, f"{table_string}{column}")# The JSON events table has no mat_* columns at all; group columns there stay String blobs.allow_denormalized_props = False@@ -78,30 +77,12 @@ def get_property_string_expr(return trim_quotes_expr(f"JSONExtractRaw({table_string}{column}, {var})"), False-def _json_events_property_expr(- property_name: PropertyName, var: str, column_ref: str, materialised_table_column: str-) -> tuple[str, bool]:- """Property value read against the native-JSON events schema.-- Typed subcolumns read like non-nullable materialized columns (missing reads ''), so callers'- denormalized-column handling applies unchanged. Dynamic properties combine the scalar path and- sub-object path for that key, preserving the logical JSON string without rebuilding the document.- """- subcolumns = (- EVENTS_PROPERTIES_JSON_SUBCOLUMNS- if materialised_table_column == "properties"- else PERSON_PROPERTIES_JSON_SUBCOLUMNS- )+def _json_events_property_expr(property_name: PropertyName, var: str, column_ref: str) -> tuple[str, bool]:scalar_value = _json_events_subcolumn_expr(property_name, var, column_ref)- if property_name in subcolumns:- if subcolumns[property_name].startswith(("Array(", "Map(")):- return f"if(empty({scalar_value}), '', toJSONString({scalar_value}))", True- return f"ifNull({scalar_value}, '')", True-- object_value = f"toJSONString({_json_events_subcolumn_expr(property_name, var, column_ref, sub_object=True)})"+ object_value = f"JSONStripEmptyStringsAndNulls(toJSONString({_json_events_subcolumn_expr(property_name, var, column_ref, sub_object=True)}))"# dynamicType only chooses scalar versus container formatting; both branches cast the# whole Dynamic value rather than selecting one physical variant.- dynamic_type = f"dynamicType({scalar_value})"+ dynamic_type = f"dynamicType(accurateCast({scalar_value}, 'Dynamic'))"is_container = " OR ".join(f"startsWith({dynamic_type}, '{family}')" for family in ("Array", "Map", "Tuple"))scalar_string = f"toString({scalar_value})"formatted_scalar = (@@ -109,9 +90,9 @@ def _json_events_property_expr()raw_value = (f"if({object_value} != '{{}}', {object_value}, "- f"if({is_container}, toJSONString({scalar_value}), {formatted_scalar}))"+ f"if({is_container}, nullIf(nullIf(toJSONString({scalar_value}), '[]'), '{{}}'), {formatted_scalar}))")- return trim_quotes_expr(f"ifNull({raw_value}, '')"), False+ return f"ifNull({raw_value}, '')", Falsedef _json_events_subcolumn_expr(diff --git a/posthog/models/raw_sessions/sessions_v2.py b/posthog/models/raw_sessions/sessions_v2.pyindex f5858c25596b..1dc052426dc6 100644--- a/posthog/models/raw_sessions/sessions_v2.py+++ b/posthog/models/raw_sessions/sessions_v2.py@@ -1,6 +1,9 @@from django.conf import settings+from posthog.hogql.escape_sql import escape_clickhouse_identifier+from posthog.clickhouse.cluster import ON_CLUSTER_CLAUSE+from posthog.clickhouse.events_json import EVENTS_PROPERTIES_JSON_SUBCOLUMNSfrom posthog.clickhouse.table_engines import AggregatingMergeTree, Distributed, ReplicationSchemefrom posthog.models.event.new_events_schema import events_read_table, use_new_events_schema@@ -170,31 +173,41 @@ SAMPLE BY cityHash64(session_id_v7))-def source_url_column(column_name: str, properties: str = "properties") -> str:- return f"nullIf(JSONExtractString({properties}, '{column_name}'), '')"+def source_string_column(column_name: str, use_new: bool = False) -> str:+ if use_new:+ column = f"properties.{escape_clickhouse_identifier(column_name)}"+ if column_name not in EVENTS_PROPERTIES_JSON_SUBCOLUMNS:+ column = f"dynamicElement({column}, 'String')"+ return f"CAST(ifNull({column}, ''), 'String')"+ return f"JSONExtractString(properties, '{column_name}')"-def source_string_column(column_name: str, properties: str = "properties") -> str:- return f"JSONExtractString({properties}, '{column_name}')"+def source_url_column(column_name: str, use_new: bool = False) -> str:+ return f"nullIf({source_string_column(column_name, use_new)}, '')"-def source_int_column(column_name: str, properties: str = "properties") -> str:- return f"JSONExtractInt({properties}, '{column_name}')"+def source_int_column(column_name: str, use_new: bool = False) -> str:+ if use_new:+ return f"JSONExtractInt({source_string_column(column_name, use_new)})"+ return f"JSONExtractInt(properties, '{column_name}')"-def source_nullable_float_column(column_name: str, properties: str = "properties") -> str:+def source_nullable_float_column(column_name: str, use_new: bool = False) -> str:+ if use_new:+ return f"accurateCastOrNull({source_string_column(column_name, use_new)}, 'Float64')"# this is what we do in queries, but it seems pretty awful- return f"""accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw({properties}, '{column_name}'), ''), 'null'), '^"|"$', ''), 'Float64')"""+ return f"""accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties, '{column_name}'), ''), 'null'), '^"|"$', ''), 'Float64')"""def RAW_SESSION_TABLE_BACKFILL_SELECT_SQL(team_id: int | None = None,*,events_table: str | None = None,- session_id_expr: str = "`$session_id`",+ session_id_expr: str | None = None,) -> str:use_new = events_table is None and use_new_events_schema(team_id)- properties = "toJSONString(properties)" if use_new else "properties"+ if session_id_expr is None:+ session_id_expr = "properties.`$session_id`" if use_new else "`$session_id`"events_table = events_table or events_read_table(use_new)return """@@ -278,46 +291,46 @@ WHERE bitAnd(bitShiftRight(toUInt128(accurateCastOrNull({session_id}, 'UUID')),database=settings.CLICKHOUSE_DATABASE,events_table=events_table,session_id=session_id_expr,- current_url=source_url_column("$current_url", properties),- current_url_string=source_string_column("$current_url", properties),- external_click_url=source_string_column("$external_click_url", properties),- browser=source_string_column("$browser", properties),- browser_version=source_string_column("$browser_version", properties),- os=source_string_column("$os", properties),- os_version=source_string_column("$os_version", properties),- device_type=source_string_column("$device_type", properties),- viewport_width=source_int_column("$viewport_width", properties),- viewport_height=source_int_column("$viewport_height", properties),- geoip_country_code=source_string_column("$geoip_country_code", properties),- geoip_subdivision_1_code=source_string_column("$geoip_subdivision_1_code", properties),- geoip_subdivision_1_name=source_string_column("$geoip_subdivision_1_name", properties),- geoip_subdivision_city_name=source_string_column("$geoip_subdivision_city_name", properties),- geoip_time_zone=source_string_column("$geoip_time_zone", properties),- referring_domain=source_string_column("$referring_domain", properties),- utm_source=source_string_column("utm_source", properties),- utm_campaign=source_string_column("utm_campaign", properties),- utm_medium=source_string_column("utm_medium", properties),- utm_term=source_string_column("utm_term", properties),- utm_content=source_string_column("utm_content", properties),- gclid=source_string_column("gclid", properties),- gad_source=source_string_column("gad_source", properties),- gclsrc=source_string_column("gclsrc", properties),- dclid=source_string_column("dclid", properties),- gbraid=source_string_column("gbraid", properties),- wbraid=source_string_column("wbraid", properties),- fbclid=source_string_column("fbclid", properties),- msclkid=source_string_column("msclkid", properties),- twclid=source_string_column("twclid", properties),- li_fat_id=source_string_column("li_fat_id", properties),- mc_cid=source_string_column("mc_cid", properties),- igshid=source_string_column("igshid", properties),- ttclid=source_string_column("ttclid", properties),- epik=source_string_column("epik", properties),- qclid=source_string_column("qclid", properties),- sccid=source_string_column("sccid", properties),- kx=source_string_column("_kx", properties),- irclid=source_string_column("irclid", properties),- vitals_lcp=source_nullable_float_column("$web_vitals_LCP_value", properties),+ current_url=source_url_column("$current_url", use_new),+ current_url_string=source_string_column("$current_url", use_new),+ external_click_url=source_string_column("$external_click_url", use_new),+ browser=source_string_column("$browser", use_new),+ browser_version=source_string_column("$browser_version", use_new),+ os=source_string_column("$os", use_new),+ os_version=source_string_column("$os_version", use_new),+ device_type=source_string_column("$device_type", use_new),+ viewport_width=source_int_column("$viewport_width", use_new),+ viewport_height=source_int_column("$viewport_height", use_new),+ geoip_country_code=source_string_column("$geoip_country_code", use_new),+ geoip_subdivision_1_code=source_string_column("$geoip_subdivision_1_code", use_new),+ geoip_subdivision_1_name=source_string_column("$geoip_subdivision_1_name", use_new),+ geoip_subdivision_city_name=source_string_column("$geoip_subdivision_city_name", use_new),+ geoip_time_zone=source_string_column("$geoip_time_zone", use_new),+ referring_domain=source_string_column("$referring_domain", use_new),+ utm_source=source_string_column("utm_source", use_new),+ utm_campaign=source_string_column("utm_campaign", use_new),+ utm_medium=source_string_column("utm_medium", use_new),+ utm_term=source_string_column("utm_term", use_new),+ utm_content=source_string_column("utm_content", use_new),+ gclid=source_string_column("gclid", use_new),+ gad_source=source_string_column("gad_source", use_new),+ gclsrc=source_string_column("gclsrc", use_new),+ dclid=source_string_column("dclid", use_new),+ gbraid=source_string_column("gbraid", use_new),+ wbraid=source_string_column("wbraid", use_new),+ fbclid=source_string_column("fbclid", use_new),+ msclkid=source_string_column("msclkid", use_new),+ twclid=source_string_column("twclid", use_new),+ li_fat_id=source_string_column("li_fat_id", use_new),+ mc_cid=source_string_column("mc_cid", use_new),+ igshid=source_string_column("igshid", use_new),+ ttclid=source_string_column("ttclid", use_new),+ epik=source_string_column("epik", use_new),+ qclid=source_string_column("qclid", use_new),+ sccid=source_string_column("sccid", use_new),+ kx=source_string_column("_kx", use_new),+ irclid=source_string_column("irclid", use_new),+ vitals_lcp=source_nullable_float_column("$web_vitals_LCP_value", use_new),)diff --git a/posthog/models/test/test_event_model.py b/posthog/models/test/test_event_model.pyindex b2b6dc1916d3..51c81d02e342 100644--- a/posthog/models/test/test_event_model.py+++ b/posthog/models/test/test_event_model.py@@ -1,15 +1,19 @@import re+from uuid import uuid4-from posthog.test.base import BaseTest+from posthog.test.base import BaseTest, ClickhouseTestMixin-from django.test import SimpleTestCase+from django.test import SimpleTestCase, override_settingsfrom parameterized import parameterized+from posthog.clickhouse.client import sync_executefrom posthog.models import Elementfrom posthog.models.element.element import elements_to_stringfrom posthog.models.event import Selector+from posthog.models.event.util import bulk_create_events, create_eventfrom posthog.models.property.util import build_selector_regex+from posthog.test.test_journeys import journeys_forclass TestSelectors(BaseTest):@@ -309,3 +313,36 @@ class TestSelectorRegexMonotonicity(SimpleTestCase):newly_matching_pairs += 1# the corpus has to exercise the widening, or the superset check is vacuousself.assertGreater(newly_matching_pairs, 0)+++@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)+class TestNativeEventInserts(ClickhouseTestMixin, BaseTest):+ @parameterized.expand(["bulk", "single", "journey"])+ def test_properties_follow_ingestion_cleanup(self, insertion: str) -> None:+ properties = {+ "$feature/enabled": True,+ "$feature/disabled": False,+ "$feature_flags": {"existing": "control"},+ "$sdk_debug_replay_internal_buffer_length": 0,+ }+ if insertion == "journey":+ journeys_for({"test": [{"event": "test", "properties": properties}]}, self.team)+ elif insertion == "bulk":+ bulk_create_events([{"team": self.team, "event": "test", "distinct_id": "test", "properties": properties}])+ else:+ create_event(event_uuid=uuid4(), team=self.team, event="test", distinct_id="test", properties=properties)++ result = sync_execute(+ "SELECT properties.`$feature_flags`, "+ "toJSONString(temporary_properties.`$sdk_debug_replay_internal_buffer_length`), "+ "isNull(properties.`$sdk_debug_replay_internal_buffer_length`) "+ "FROM events_json WHERE team_id = %(team_id)s",+ {"team_id": self.team.pk},+ )+ assert result == [+ (+ {"disabled": "false", "enabled": "true", "existing": "control"},+ "0",+ 1,+ )+ ]diff --git a/posthog/session_recordings/queries/session_replay_events.py b/posthog/session_recordings/queries/session_replay_events.pyindex ecef5238332c..78aeab6a20ba 100644--- a/posthog/session_recordings/queries/session_replay_events.py+++ b/posthog/session_recordings/queries/session_replay_events.py@@ -2,7 +2,7 @@ import reimport jsonfrom dataclasses import dataclassfrom datetime import datetime, timedelta-from typing import Optional+from typing import TYPE_CHECKING, Optionalfrom django.core.cache import cache@@ -10,12 +10,25 @@ import pytzfrom posthog.schema import HogQLQuery+from posthog.hogql.escape_sql import escape_clickhouse_identifier+from posthog.clickhouse.client import sync_executefrom posthog.clickhouse.client.connection import ClickHouseUser+from posthog.clickhouse.events_json import DISTRIBUTED_EVENTS_JSON_TABLEfrom posthog.clickhouse.query_tagging import Feature, Product, tag_queries+from posthog.models.event.new_events_schema import use_new_events_schemafrom posthog.models.team import Teamfrom posthog.session_recordings.models.metadata import ONGOING_SESSION_WINDOW_MINUTES, RecordingMetadata+from products.access_control.backend.property_access_control import (+ get_restricted_property_names,+ strip_restricted_properties,+)+from products.event_definitions.backend.models.property_definition import PropertyDefinition++if TYPE_CHECKING:+ from posthog.models import User+DEFAULT_EVENT_FIELDS = ["event","timestamp",@@ -120,7 +133,7 @@ def _filter_to_diagnostic_properties(properties: dict) -> dict:}-def get_latest_session_event_properties(session_id: str, team: Team) -> Optional[dict]:+def get_latest_session_event_properties(session_id: str, team: Team, user: Optional["User"] = None) -> Optional[dict]:"""The most recent event's recording-diagnostic properties for a session, for the capture diagnostics panel.Bounded by a window derived from the UUIDv7 session id so the events sort key@@ -135,22 +148,57 @@ def get_latest_session_event_properties(session_id: str, team: Team) -> Optional# lower_bound is embedded_start - slack; sessions last at most a day,# so embedded_start + 1d + slack closes the window symmetrically.upper_bound = lower_bound + 2 * SESSION_ID_CLOCK_SKEW_SLACK + timedelta(days=1)- properties = _latest_session_event_properties_between(session_id, team, lower_bound, upper_bound)+ properties = _latest_session_event_properties_between(session_id, team, user, lower_bound, upper_bound)if properties is not None:return propertiesnow = datetime.now(pytz.UTC)return _latest_session_event_properties_between(- session_id, team, now - CAPTURE_DIAGNOSTICS_FALLBACK_LOOKBACK, now + timedelta(days=1)+ session_id, team, user, now - CAPTURE_DIAGNOSTICS_FALLBACK_LOOKBACK, now + timedelta(days=1))def _latest_session_event_properties_between(- session_id: str, team: Team, date_from: datetime, date_to: datetime+ session_id: str, team: Team, user: Optional["User"], date_from: datetime, date_to: datetime) -> Optional[dict]:from posthog.hogql_queries.hogql_query_runner import (HogQLQueryRunner, # noqa: PLC0415 — breaks a circular import, matching this file's other HogQLQueryRunner imports)+ tag_queries(product=Product.REPLAY, feature=Feature.QUERY, team_id=team.pk)+ restricted_properties = get_restricted_property_names(+ team_id=team.pk, user=user, property_type=PropertyDefinition.Type.EVENT+ )+ if use_new_events_schema(team.pk):+ property_names = sorted(_DIAGNOSTIC_PROPERTIES - {"$session_recording_remote_config"} - restricted_properties)+ fields = ", ".join(f"toJSONString(properties.{escape_clickhouse_identifier(key)})" for key in property_names)+ # The open-ended SDK debug prefix requires the temporary bag, limited to one event.+ native_query = f"""+ SELECT {fields}, toJSONString(temporary_properties)+ FROM {DISTRIBUTED_EVENTS_JSON_TABLE}+ WHERE team_id = %(team_id)s+ AND properties.`$session_id` = %(session_id)s+ AND timestamp >= %(date_from)s+ AND timestamp <= %(date_to)s+ ORDER BY timestamp DESC+ LIMIT 1+ """+ rows = sync_execute(+ native_query,+ {"team_id": team.pk, "session_id": session_id, "date_from": date_from, "date_to": date_to},+ team_id=team.pk,+ ch_user=ClickHouseUser.APP,+ )+ if not rows:+ return None+ properties = {key: json.loads(value) for key, value in zip(property_names, rows[0][:-1]) if value is not None}+ properties = {key: value for key, value in properties.items() if value is not None and value != ""}+ properties.update(+ strip_restricted_properties(+ _filter_to_diagnostic_properties(json.loads(rows[0][-1])), restricted_properties+ )+ )+ return properties+query = HogQLQuery(query="""SELECT properties@@ -163,8 +211,7 @@ def _latest_session_event_properties_between(""",values={"session_id": session_id, "date_from": date_from, "date_to": date_to},)- tag_queries(product=Product.REPLAY, feature=Feature.QUERY, team_id=team.pk)- result = HogQLQueryRunner(team=team, query=query).calculate()+ result = HogQLQueryRunner(team=team, user=user, query=query).calculate()if not result.results:return Nonerow = result.results[0][0]diff --git a/posthog/session_recordings/queries/test/test_session_replay_events.py b/posthog/session_recordings/queries/test/test_session_replay_events.pyindex fbd6375f8787..8d0c5727c5b0 100644--- a/posthog/session_recordings/queries/test/test_session_replay_events.py+++ b/posthog/session_recordings/queries/test/test_session_replay_events.py@@ -1,4 +1,7 @@+import json+from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event+from unittest.mock import patchfrom django.core.cache import cachefrom django.utils.timezone import now@@ -492,6 +495,8 @@ class TestGetLatestSessionEventProperties(ClickhouseTestMixin, APIBaseTest):"$session_id": session_id,"$recording_status": "disabled","$sdk_debug_replay_internal_buffer_length": 0,+ "$session_recording_remote_config": {"sampleRate": 0.5},+ "$set": {"email": "[email protected]"},"$current_url": "https://example.com/private-path","email": "[email protected]",},@@ -502,8 +507,30 @@ class TestGetLatestSessionEventProperties(ClickhouseTestMixin, APIBaseTest):assert properties == {"$recording_status": "disabled","$sdk_debug_replay_internal_buffer_length": 0,+ "$session_recording_remote_config": {"sampleRate": 0.5},}+ def test_native_schema_filters_restricted_diagnostic_properties(self) -> None:+ restricted = {"$recording_status", "$sdk_debug_secret"}+ temporary_properties = json.dumps(+ {"$recording_status": "hidden", "$sdk_debug_secret": "hidden", "$sdk_debug_visible": "visible"}+ )+ with (+ patch("posthog.session_recordings.queries.session_replay_events.use_new_events_schema", return_value=True),+ patch(+ "posthog.session_recordings.queries.session_replay_events.get_restricted_property_names",+ return_value=restricted,+ ),+ patch(+ "posthog.session_recordings.queries.session_replay_events.sync_execute",+ return_value=[(temporary_properties,)],+ ) as execute,+ ):+ properties = get_latest_session_event_properties("session-id", self.team, self.user)++ assert properties == {"$sdk_debug_visible": "visible"}+ assert "properties.`$recording_status`" not in execute.call_args.args[0]+def test_returns_none_when_session_has_no_events(self) -> None:session_id = _uuidv7_session_id_for(now() - relativedelta(minutes=10))diff --git a/posthog/session_recordings/session_recording_api.py b/posthog/session_recordings/session_recording_api.pyindex 1ddb26afbcf4..9cc4fcd5f3b4 100644--- a/posthog/session_recordings/session_recording_api.py+++ b/posthog/session_recordings/session_recording_api.py@@ -1017,7 +1017,8 @@ class SessionRecordingViewSet("""Latest event properties for the recording's session, for the capture diagnostics panel."""recording = self.get_object()try:- properties = get_latest_session_event_properties(str(recording.session_id), self.team)+ user = request.user if isinstance(request.user, User) else None+ properties = get_latest_session_event_properties(str(recording.session_id), self.team, user)except Exception as e:# This panel is supplementary - a ClickHouse blip shouldn't 500 the whole endpoint,# it should just render empty like a session with no matching event would.diff --git a/posthog/tasks/usage_report.py b/posthog/tasks/usage_report.pyindex 8457db7d4954..104320b000f3 100644--- a/posthog/tasks/usage_report.py+++ b/posthog/tasks/usage_report.py@@ -35,6 +35,7 @@ from posthog.dataclasses import frozenfrom posthog.exceptions_capture import capture_exceptionfrom posthog.logging.timing import timed_logfrom posthog.models import OrganizationMembership, User+from posthog.models.ai_events.sql import TABLE_BASE_NAME as AI_EVENTS_TABLEfrom posthog.models.event.new_events_schema import events_read_table, use_new_events_schemafrom posthog.models.group_type_mapping import count_group_type_mappings_per_team, get_group_types_for_teamfrom posthog.models.organization import Organization@@ -1848,9 +1849,16 @@ def _get_teams_with_ai_credits_for_products(trace_id_expr, _ = get_property_string_expr("events", "$ai_trace_id", "'$ai_trace_id'", "properties", use_new_events_schema=use_new)- output_state_expr, _ = get_property_string_expr(- "events", "$ai_output_state", "'$ai_output_state'", "properties", use_new_events_schema=use_new- )+ output_state_expr, _ = get_property_string_expr("events", "$ai_output_state", "'$ai_output_state'", "properties")+ trace_events_table = events_table+ trace_analysis_id_expr = trace_id_expr+ trace_region_expr = region_expr+ if use_new:+ # Native shared events omit the output state needed to identify free tool calls.+ trace_events_table = AI_EVENTS_TABLE+ trace_analysis_id_expr = "trace_id"+ trace_region_expr = "JSONExtractString(properties, %(region_group_property)s)"+ output_state_expr = "ifNull(output_state, '')"customer_team_id_expr, _ = get_property_string_expr("events", "team_id", "'team_id'", "properties", use_new_events_schema=use_new)@@ -1897,7 +1905,7 @@ def _get_teams_with_ai_credits_for_products() AS is_billableFROM (SELECT- {trace_id_expr} AS trace_id,+ {trace_analysis_id_expr} AS trace_id,arrayFlatten(arrayMap(msg -> JSONExtractArrayRaw(msg, 'tool_calls'),@@ -1913,11 +1921,11 @@ def _get_teams_with_ai_credits_for_products()) AS tool_calls,arrayMap(tc -> JSONExtractString(tc, 'name'), tool_calls) AS tool_names- FROM {events_table}+ FROM {trace_events_table}PREWHERE-- data inside PostHog project used as ground truth for billing (depends on region)team_id = %(team_to_query)s- AND {region_expr} = %(region_url)s+ AND {trace_region_expr} = %(region_url)sAND timestamp >= %(begin)sAND timestamp < %(end)sAND event = '$ai_trace'diff --git a/posthog/test/test_journeys.py b/posthog/test/test_journeys.pyindex 7c36809546b8..6396ea0f64e7 100644--- a/posthog/test/test_journeys.py+++ b/posthog/test/test_journeys.py@@ -13,7 +13,7 @@ from django.utils import timezonefrom posthog.clickhouse.client import sync_executefrom posthog.models import Person, Team-from posthog.models.event.sql import EVENTS_DATA_TABLE, EVENTS_JSON_DATA_TABLE+from posthog.models.event.sql import BULK_INSERT_EVENT_SQL, EVENTS_DATA_TABLE, EVENTS_JSON_DATA_TABLEfrom posthog.models.event.util import _json_dumps_for_clickhousefrom posthog.models.group.util import get_group_by_keyfrom posthog.models.person.util import get_person_by_distinct_id@@ -128,8 +128,8 @@ def journeys_for(def _create_all_events_raw(all_events: list[dict]):- legacy_rows = ""- json_rows = ""+ legacy_rows = []+ json_rows = []for event in all_events:timestamp = timezone.now()data: dict[str, Any] = {@@ -164,23 +164,27 @@ def _create_all_events_raw(all_events: list[dict]):data[key] = timestampin_memory_event = InMemoryEvent(**data)created_at = timezone.now().strftime("%Y-%m-%d %H:%M:%S.%f")- legacy_rows += _event_row_values(- in_memory_event,- properties=json.dumps(in_memory_event.properties),- person_properties=json.dumps(in_memory_event.person_properties),- created_at=created_at,- )- if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:- json_rows += _event_row_values(+ legacy_rows.append(+ _event_row_values(in_memory_event,- properties=_json_dumps_for_clickhouse(in_memory_event.properties),- person_properties=_json_dumps_for_clickhouse(in_memory_event.person_properties),+ properties=json.dumps(in_memory_event.properties),+ person_properties=json.dumps(in_memory_event.person_properties),created_at=created_at,)+ )+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ json_rows.append(+ _event_row_values(+ in_memory_event,+ properties=_json_dumps_for_clickhouse(in_memory_event.properties),+ person_properties=_json_dumps_for_clickhouse(in_memory_event.person_properties),+ created_at=created_at,+ )+ )- _insert_event_rows_raw(EVENTS_DATA_TABLE(), legacy_rows)+ _insert_event_rows_raw(EVENTS_DATA_TABLE(), ", ".join(legacy_rows))if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:- _insert_event_rows_raw(EVENTS_JSON_DATA_TABLE, json_rows)+ _insert_event_rows_raw(EVENTS_JSON_DATA_TABLE, ", ".join(json_rows))def _event_row_values(@@ -211,6 +215,7 @@ def _event_row_values(f"'{_format_clickhouse_timestamp(in_memory_event.group2_created_at)}'",f"'{_format_clickhouse_timestamp(in_memory_event.group3_created_at)}'",f"'{_format_clickhouse_timestamp(in_memory_event.group4_created_at)}'",+ "'full'",f"'{created_at}'","now()","0",@@ -223,12 +228,7 @@ def _format_clickhouse_timestamp(value: datetime) -> str:def _insert_event_rows_raw(table_name: str, rows: str) -> None:- sync_execute(- f"""- INSERT INTO {table_name} (uuid, event, properties, timestamp, team_id, distinct_id, elements_chain, person_id, person_properties, person_created_at, group0_properties, group1_properties, group2_properties, group3_properties, group4_properties, group0_created_at, group1_created_at, group2_created_at, group3_created_at, group4_created_at, created_at, _timestamp, _offset) VALUES- {rows}- """- )+ sync_execute(BULK_INSERT_EVENT_SQL(table_name=table_name, values=rows))def create_all_events(all_events: list[dict]):diff --git a/products/access_control/backend/facade/api.py b/products/access_control/backend/facade/api.pyindex 81b713090abe..03b7b8491b82 100644--- a/products/access_control/backend/facade/api.py+++ b/products/access_control/backend/facade/api.py@@ -23,15 +23,21 @@ from uuid import UUIDfrom django.shortcuts import get_object_or_404+from posthog.hogql.property_access_types import RestrictedProperty+from posthog.constants import AvailableFeaturefrom posthog.models import Organization, OrganizationMembership, PropertyDefinition, Team+from posthog.models.user import Userfrom posthog.scopes import API_SCOPE_OBJECTS, INTERNAL_API_SCOPE_OBJECTS, APIScopeObjectfrom products.access_control.backend.models.role import Rolefrom ..models.access_control import AccessControlfrom ..models.property_access_control import PropertyAccessControl-from ..property_access_control import is_property_access_control_enabled+from ..property_access_control import (+ get_restricted_properties_with_group_type_index_for_team as _get_restricted_properties_with_group_type_index_for_team,+ is_property_access_control_enabled,+)from . import contractsfrom .contracts import PropertyAccessLevelfrom .user_access_control import (@@ -98,6 +104,29 @@ def _get_property_definition(property_definition_id: str, team_id: int) -> Prope# --- Read API ---+def get_restricted_properties_with_group_type_index_for_team(+ *, user: User | None, team_id: int+) -> set[RestrictedProperty]:+ """Return property restrictions for a user and team."""+ return _get_restricted_properties_with_group_type_index_for_team(user=user, team_id=team_id)+++def split_restricted_property_names(restrictions: set[RestrictedProperty]) -> contracts.RestrictedPropertyNames:+ """Return restricted event and person property names."""+ return contracts.RestrictedPropertyNames(+ event=frozenset(+ restriction.name+ for restriction in restrictions+ if restriction.property_type == PropertyDefinition.Type.EVENT+ ),+ person=frozenset(+ restriction.name+ for restriction in restrictions+ if restriction.property_type == PropertyDefinition.Type.PERSON+ ),+ )++def get_property_access_state(*,team_id: int,diff --git a/products/access_control/backend/facade/contracts.py b/products/access_control/backend/facade/contracts.pyindex 136ae1978651..474a142dccf4 100644--- a/products/access_control/backend/facade/contracts.py+++ b/products/access_control/backend/facade/contracts.py@@ -26,6 +26,14 @@ class PropertyAccessLevel(str, Enum):# --- Output DTOs ---+@dataclass(frozen=True)+class RestrictedPropertyNames:+ """Restricted property names grouped by event and person scope."""++ event: frozenset[str]+ person: frozenset[str]++@dataclass(frozen=True)class PropertyAccessControlRule:"""A single access control rule for a property definition."""diff --git a/products/ai_observability/backend/api/test/test_summarization.py b/products/ai_observability/backend/api/test/test_summarization.pyindex 81bd2d3d3ce1..1585f4552089 100644--- a/products/ai_observability/backend/api/test/test_summarization.py+++ b/products/ai_observability/backend/api/test/test_summarization.py@@ -11,6 +11,8 @@ from typing import Anyfrom posthog.test.base import APIBaseTest, ClickhouseTestMixinfrom unittest.mock import patch+from django.conf import settings+from parameterized import parameterizedfrom rest_framework import status@@ -501,7 +503,6 @@ class TestSummarizationByID(ClickhouseTestMixin, APIBaseTest):@patch("products.ai_observability.backend.api.summarization.summarize")def test_summarizes_an_event_predating_the_ai_events_split(self, mock_summarize):- """Events older than the ai_events retention window still hold their content inline."""self._approve_ai_processing()mock_summarize.return_value = SummarizationResponse(title="Event Summary",@@ -539,8 +540,13 @@ class TestSummarizationByID(ClickhouseTestMixin, APIBaseTest):format="json",)- self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)- self.assertIn("how do i reset my password", response.data["text_repr"].lower())+ if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA:+ self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND, response.data)+ self.assertIn("message content for this event is no longer available", response.data["detail"])+ mock_summarize.assert_not_called()+ else:+ self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)+ self.assertIn("how do i reset my password", response.data["text_repr"].lower())def test_unknown_event_uuid_is_reported_as_not_found(self):self._approve_ai_processing()diff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/api/batch_export.pyindex 47b234f9b8b5..d6ab3671bbd3 100644--- a/products/batch_exports/backend/api/batch_export.py+++ b/products/batch_exports/backend/api/batch_export.py@@ -5,7 +5,7 @@ import datetime as dtimport dataclassesimport collections.abcfrom dataclasses import dataclass-from typing import Any, TypedDict, cast+from typing import Any, castfrom django.conf import settingsfrom django.db import models, transaction@@ -19,14 +19,14 @@ from rest_framework import filters, mixins, request, response, serializers, statfrom rest_framework.exceptions import APIException, NotAuthenticated, NotFound, PermissionDenied, ValidationErrorfrom rest_framework.pagination import CursorPagination-from posthog.schema import HogQLQueryModifiers, PersonsOnEventsMode+from posthog.schema import HogQLQueryModifiers, MaterializationMode, PersonsOnEventsModefrom posthog.hogql import ast, errors-from posthog.hogql.escape_sql import escape_clickhouse_identifierfrom posthog.hogql.hogql import HogQLContextfrom posthog.hogql.parser import parse_select-from posthog.hogql.printer import prepare_ast_for_printing, print_prepared_ast-from posthog.hogql.visitor import TraversingVisitor+from posthog.hogql.printer import prepare_ast_for_printing+from posthog.hogql.resolver import resolve_types+from posthog.hogql.visitor import TraversingVisitor, clone_exprfrom posthog.api.log_entries import LogEntryMixinfrom posthog.api.routing import TeamAndOrgViewSetMixin@@ -52,7 +52,9 @@ from posthog.security.url_validation import (from posthog.temporal.common.client import sync_connectfrom posthog.utils import relative_date_parse, str_to_bool+from products.access_control.backend.facade.api import get_restricted_properties_with_group_type_index_for_teamfrom products.batch_exports.backend.api.destination_tests import get_destination_test+from products.batch_exports.backend.hogql_source import serialize_batch_export_queryfrom products.batch_exports.backend.models.batch_export import (BATCH_EXPORT_INTERVALS,OBJECT_STORAGE_DESTINATIONS,@@ -1093,38 +1095,37 @@ class HogQLSelectQueryField(serializers.Field):raise serializers.ValidationError("Failed to parse query")try:- prepared_select_query: ast.SelectQuery = cast(+ restricted_properties = get_restricted_properties_with_group_type_index_for_team(+ user=self.context["request"].user, team_id=self.context["team_id"]+ )+ context = HogQLContext(+ team_id=self.context["team_id"],+ user=self.context["request"].user,+ enable_select_queries=True,+ restricted_properties=restricted_properties,+ modifiers=HogQLQueryModifiers(+ personsOnEventsMode=PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS+ ),+ )+ if restricted_properties:+ # A restricted query is stored without its HogQL text, so no run can recompile it for+ # the native source, where a materialized column does not exist.+ context.modifiers.materializationMode = MaterializationMode.DISABLED+ use_native_schema = context.uses_new_events_schema()+ prepared_select_query = cast(ast.SelectQuery,prepare_ast_for_printing(- parsed_query,- context=HogQLContext(- team_id=self.context["team_id"],- user=self.context["request"].user,- enable_select_queries=True,- modifiers=HogQLQueryModifiers(- personsOnEventsMode=PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS- ),- ),- dialect="clickhouse",+ parsed_query, context=context, dialect="hogql" if use_native_schema else "clickhouse"),)+ if use_native_schema:+ resolve_types(clone_expr(parsed_query, clear_types=True), context=context, dialect="clickhouse")except errors.ExposedHogQLError as e:raise serializers.ValidationError(f"Invalid HogQL query: {e}")return prepared_select_query-class BatchExportsField(TypedDict):- expression: str- alias: str---class BatchExportsSchema(TypedDict):- fields: list[BatchExportsField]- values: dict[str, Any]- hogql_query: str--class _SubqueryFinder(TraversingVisitor):"""Walk an AST subtree and flag if any SelectQuery or SelectSetQuery is found."""@@ -1728,62 +1729,30 @@ class BatchExportSerializer(serializers.ModelSerializer):def serialize_hogql_query_to_batch_export_schema(self, hogql_query: ast.SelectQuery) -> BatchExportSchema:"""Return a batch export schema from a HogQL query ast."""+ request = self.context.get("request")+ user = request.user if request is not None else None+ restricted_properties = get_restricted_properties_with_group_type_index_for_team(+ user=user, team_id=self.context["team_id"]+ )+ context = HogQLContext(+ team_id=self.context["team_id"],+ user=user,+ enable_select_queries=True,+ limit_top_select=False,+ restricted_properties=restricted_properties,+ modifiers=HogQLQueryModifiers(+ personsOnEventsMode=PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS,+ ),+ )+ if context.uses_new_events_schema():+ context.modifiers.materializationMode = MaterializationMode.DISABLEDtry:- # Print the query in ClickHouse dialect to catch unresolved field errors, and discard the result- context = HogQLContext(- team_id=self.context["team_id"],- enable_select_queries=True,- limit_top_select=False,- modifiers=HogQLQueryModifiers(- personsOnEventsMode=PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS- ),- )- print_prepared_ast(hogql_query, context=context, dialect="clickhouse")-- # Recreate the context- context = HogQLContext(- team_id=self.context["team_id"],- enable_select_queries=True,- limit_top_select=False,- )- batch_export_schema: BatchExportsSchema = {- "fields": [],- "values": {},- "hogql_query": print_prepared_ast(hogql_query, context=context, dialect="hogql"),- }+ schema = serialize_batch_export_query(hogql_query, context)except errors.ExposedHogQLError:raise serializers.ValidationError("Unsupported HogQL query")-- for field in hogql_query.select:- if isinstance(field, ast.Alias):- expression = print_prepared_ast(- field.expr,- context=context,- dialect="clickhouse",- )- alias = escape_clickhouse_identifier(field.alias)- else:- expression = print_prepared_ast(- field,- context=context,- dialect="clickhouse",- )- # String constants get parameterized by the ClickHouse printer (e.g., 'hello' becomes- # %(hogql_val_0)s), which escape_clickhouse_identifier rejects. Use the raw value instead.- if isinstance(field, ast.Constant) and isinstance(field.value, str):- alias = escape_clickhouse_identifier(field.value)- else:- alias = escape_clickhouse_identifier(expression)-- batch_export_field: BatchExportsField = {- "expression": expression,- "alias": alias,- }- batch_export_schema["fields"].append(batch_export_field)-- batch_export_schema["values"] = context.values-- return batch_export_schema+ if context.restricted_properties:+ schema.pop("hogql_query", None)+ return schemadef validate_hogql_query(self, hogql_query: ast.SelectQuery | ast.SelectSetQuery) -> ast.SelectQuery:"""Validate a HogQL query being used for events batch exports.diff --git a/products/batch_exports/backend/debug/debugger.py b/products/batch_exports/backend/debug/debugger.pyindex 31171dc774f3..2f2dfeba23fd 100644--- a/products/batch_exports/backend/debug/debugger.py+++ b/products/batch_exports/backend/debug/debugger.py@@ -16,6 +16,7 @@ import pyarrow.fs as fsimport pyarrow.ipc as ipcfrom rich.console import Console+from posthog.models.event.new_events_schema import use_new_events_schemafrom posthog.models.integration import DatabricksIntegrationfrom posthog.temporal.common.clickhouse import ClickHouseClient@@ -49,6 +50,7 @@ from products.batch_exports.backend.temporal.sql.events import (SELECT_FROM_EVENTS_VIEW_BACKFILL,SELECT_FROM_EVENTS_VIEW_RECENT,SELECT_FROM_EVENTS_VIEW_UNBOUNDED,+ native_events_export_query,)from products.batch_exports.backend.temporal.sql.persons import SELECT_FROM_PERSONS, SELECT_FROM_PERSONS_BACKFILL@@ -389,9 +391,11 @@ class BatchExportsDebugger:) -> collections.abc.Generator[pa.RecordBatch]:team_id = batch_export_run.parent.team.idfull_range = (batch_export_run.data_interval_start, batch_export_run.data_interval_end)- parameters = {"team_id": team_id, "interval_end": full_range[1].strftime("%Y-%m-%d %H:%M:%S.%f")}- if full_range[0]:- parameters["interval_start"] = full_range[0].strftime("%Y-%m-%d %H:%M:%S.%f")+ parameters: dict[str, typing.Any] = {+ "team_id": team_id,+ "interval_start": full_range[0].strftime("%Y-%m-%d %H:%M:%S.%f") if full_range[0] else None,+ "interval_end": full_range[1].strftime("%Y-%m-%d %H:%M:%S.%f"),+ }extra_query_parameters: dict[str, str] = {}filters = batch_export_run.parent.filters@@ -469,10 +473,12 @@ class BatchExportsDebugger:query_fields = ",".join(f"{field['expression']} AS {field['alias']}" for field in fields + control_fields)- if filters_str:- filters_str = f"AND {filters_str}"-- query = query_template.safe_substitute(fields=query_fields, filters=filters_str, order="")+ if query_template is SELECT_FROM_EVENTS_VIEW_BACKFILL and use_new_events_schema(team_id):+ query = native_events_export_query(query_fields, filters_str)+ else:+ if filters_str:+ filters_str = f"AND {filters_str}"+ query = query_template.safe_substitute(fields=query_fields, filters=filters_str, order="")parameters = {**parameters, **extra_query_parameters}diff --git a/products/batch_exports/backend/hogql_source.py b/products/batch_exports/backend/hogql_source.pyindex 4e73ba888587..2801ab8924ca 100644--- a/products/batch_exports/backend/hogql_source.py+++ b/products/batch_exports/backend/hogql_source.py@@ -9,15 +9,21 @@ import typingfrom posthog.hogql import astfrom posthog.hogql.context import HogQLContextfrom posthog.hogql.database.database import Database-from posthog.hogql.errors import ExposedHogQLError+from posthog.hogql.errors import ExposedHogQLError, QueryError+from posthog.hogql.escape_sql import escape_clickhouse_identifierfrom posthog.hogql.modifiers import create_default_modifiers_for_teamfrom posthog.hogql.parser import parse_selectfrom posthog.hogql.placeholders import find_placeholders-from posthog.hogql.printer import prepare_ast_for_printing+from posthog.hogql.printer import prepare_ast_for_printing, print_prepared_ast+from posthog.hogql.visitor import CloningVisitor++from posthog.clickhouse.events_json import UNPARSEABLE_PROPERTIES_KEYif typing.TYPE_CHECKING:from posthog.models import Team+ from products.batch_exports.backend.service import BatchExportField, BatchExportSchema+class UnsupportedHogQLQueryError(Exception):"""Raised when a HogQL query cannot be used to power a batch export."""@@ -110,3 +116,96 @@ def validate_hogql_query_for_batch_export(hogql_query: str, team: "Team") -> Nonprepare_ast_for_printing(parsed, context=context, dialect="clickhouse", stack=[])except ExposedHogQLError as e:raise UnsupportedHogQLQueryError(f"Invalid HogQL query: {e}") from e+++class SerializedExportProperties(CloningVisitor):+ """Rebind event fields while preserving property access restrictions."""++ def __init__(self, table_alias: str, context: HogQLContext) -> None:+ super().__init__()+ self.table_alias = table_alias++ from products.access_control.backend.facade.api import ( # noqa: PLC0415 — keeps Django access-control imports off the batch worker import path+ split_restricted_property_names,+ )++ restrictions = context.restricted_properties or set()+ restricted_names = split_restricted_property_names(restrictions)+ self.event_restrictions = set(restricted_names.event)+ self.person_restrictions = set(restricted_names.person)+ if restrictions and context.uses_new_events_schema():+ self.event_restrictions.add(UNPARSEABLE_PROPERTIES_KEY)+ self.person_restrictions.add(UNPARSEABLE_PROPERTIES_KEY)++ def visit_field(self, node: ast.Field) -> ast.Expr:+ node = super().visit_field(node)+ if node.chain[0] == self.table_alias:+ node.chain[0] = "events"+ index = 1 if node.chain[0] == "events" else 0+ if len(node.chain) <= index:+ return node+ if node.chain[index : index + 2] == ["person", "properties"]:+ # `poe.properties` is the events table's own copy of the person properties.+ node.chain[index : index + 2] = ["poe", "properties"]+ if node.chain[index : index + 2] == ["poe", "properties"]:+ restrictions, property_chain = self.person_restrictions, node.chain[index + 2 :]+ elif str(node.chain[index]) == "properties":+ restrictions, property_chain = self.event_restrictions, node.chain[index + 1 :]+ else:+ return node+ if restrictions:+ property_path = ".".join(str(part) for part in property_chain)+ if not property_path:+ raise QueryError("Batch export queries cannot select a restricted properties object")+ if any(+ property_path == key or property_path.startswith(key + ".") or key.startswith(property_path + ".")+ for key in restrictions+ ):+ return ast.Constant(value=None)+ return node+++def prepare_serialized_export_query(query: ast.SelectQuery, context: HogQLContext) -> ast.SelectQuery:+ """Resolve a HogQL query the way the export SQL reads it."""+ assert query.select_from is not None+ query = SerializedExportProperties(query.select_from.alias or "events", context).visit(query)+ assert query.select_from is not None+ # The export SQL names its source `events`, so a user alias must not reach the printed fields.+ query.select_from.alias = None+ # Every export template hands the fields a String `properties`, the native source included, so+ # the legacy shape is the one form valid on both. Resolving against the events table rather than+ # a subquery is also what lets the swapper keep the cast a typed property needs.+ context.use_new_events_schema = False+ return typing.cast(ast.SelectQuery, prepare_ast_for_printing(query, context=context, dialect="clickhouse"))+++def serialize_batch_export_query(query: ast.SelectQuery, context: HogQLContext) -> "BatchExportSchema":+ """Compile a HogQL query into stable ClickHouse expressions and aliases."""+ if context.uses_new_events_schema():+ hogql = print_prepared_ast(query, context=context, dialect="hogql")+ query = prepare_serialized_export_query(typing.cast(ast.SelectQuery, parse_select(hogql)), context)+ stack = [query]+ else:+ print_prepared_ast(query, context=context, dialect="clickhouse")+ context = HogQLContext(+ team_id=context.team_id,+ enable_select_queries=True,+ limit_top_select=False,+ use_new_events_schema=False,+ )+ stack = []+ hogql = print_prepared_ast(query, context=context, dialect="hogql")+ fields: list[BatchExportField] = []+ for field in query.select:+ if isinstance(field, ast.Alias):+ expression = print_prepared_ast(field.expr, context=context, dialect="clickhouse", stack=stack)+ alias = escape_clickhouse_identifier(field.alias)+ else:+ expression = print_prepared_ast(field, context=context, dialect="clickhouse", stack=stack)+ # String constants get parameterized by the ClickHouse printer (e.g., 'hello' becomes+ # %(hogql_val_0)s), which escape_clickhouse_identifier rejects. Use the raw value instead.+ alias = escape_clickhouse_identifier(+ field.value if isinstance(field, ast.Constant) and isinstance(field.value, str) else expression+ )+ fields.append({"expression": expression, "alias": alias})+ return {"fields": fields, "values": context.values, "hogql_query": hogql}diff --git a/products/batch_exports/backend/service.py b/products/batch_exports/backend/service.pyindex 28ffb257ca01..67d339948373 100644--- a/products/batch_exports/backend/service.py+++ b/products/batch_exports/backend/service.py@@ -137,6 +137,7 @@ class BatchExportField(typing.TypedDict):class BatchExportSchema(typing.TypedDict):+ hogql_query: typing.NotRequired[str]fields: list[BatchExportField]# HogQL binds these at any type; narrowing breaks Temporal input decoding.values: dict[str, typing.Any]diff --git a/products/batch_exports/backend/temporal/batch_exports.py b/products/batch_exports/backend/temporal/batch_exports.pyindex 735b6e578966..cb53f092044a 100644--- a/products/batch_exports/backend/temporal/batch_exports.py+++ b/products/batch_exports/backend/temporal/batch_exports.py@@ -4,6 +4,7 @@ import asyncioimport datetime as dtimport dataclassesimport collections.abc+from string import Templatefrom zoneinfo import ZoneInfofrom django.conf import settings@@ -48,6 +49,7 @@ from products.batch_exports.backend.temporal.sql.events import (SELECT_FROM_EVENTS_VIEW_BACKFILL,SELECT_FROM_EVENTS_VIEW_RECENT,SELECT_FROM_EVENTS_VIEW_UNBOUNDED,+ native_events_export_query,)from products.notifications.backend.facade.api import (NotificationData,@@ -197,6 +199,67 @@ class TaskNotDoneError(Exception):super().__init__(f"Expected task '{task}' to be done by now")+def select_events_query_template(+ *,+ team_id: int,+ interval_start: str | None,+ interval_end: str,+ is_backfill: bool = False,+ backfill_details: BackfillDetails | None = None,+) -> Template:+ start_at = dt.datetime.fromisoformat(interval_start) if interval_start is not None else None+ end_at = dt.datetime.fromisoformat(interval_end)++ # TODO: this can be simplified once all backfill inputs are migrated+ is_backfill = (backfill_details is not None) or is_backfill+ is_5_min_batch_export = start_at is not None and (end_at - start_at) == dt.timedelta(seconds=300)++ # for 5 min batch exports we query the events_recent table, which is known to have zero replication lag, but+ # may not be able to handle the load from all batch exports+ if is_5_min_batch_export and not is_backfill:+ return SELECT_FROM_EVENTS_VIEW_RECENT+ # for other batch exports that should use `events_recent` we use the `distributed_events_recent` table+ # which is a distributed table that sits in front of the `events_recent` table+ if use_distributed_events_recent_table(+ is_backfill=is_backfill, backfill_details=backfill_details, data_interval_start=start_at+ ):+ return SELECT_FROM_DISTRIBUTED_EVENTS_RECENT+ if str(team_id) in settings.UNCONSTRAINED_TIMESTAMP_TEAM_IDS:+ return SELECT_FROM_EVENTS_VIEW_UNBOUNDED+ if is_backfill:+ return SELECT_FROM_EVENTS_VIEW_BACKFILL+ return SELECT_FROM_EVENTS_VIEW+++def reads_native_events_source(+ *,+ use_new_events_schema: bool,+ team_id: int,+ interval_start: str | None,+ interval_end: str,+ is_backfill: bool = False,+ backfill_details: BackfillDetails | None = None,+) -> bool:+ """Whether a run reads the native events source instead of a legacy events table.++ Only the native source projects the `$unset` and `$group_set` columns, so a caller that asks for+ them on a run routed to a legacy table builds a query ClickHouse cannot resolve. The routing is+ wider than `is_backfill`: a backfill over recent data still reads `distributed_events_recent`.+ """+ if not use_new_events_schema:+ return False+ return (+ select_events_query_template(+ team_id=team_id,+ interval_start=interval_start,+ interval_end=interval_end,+ is_backfill=is_backfill,+ backfill_details=backfill_details,+ )+ is SELECT_FROM_EVENTS_VIEW_BACKFILL+ )++def iter_records(client: ClickHouseClient,team_id: int,@@ -209,6 +272,8 @@ def iter_records(extra_query_parameters: dict[str, typing.Any] | None = None,is_backfill: bool = False,backfill_details: BackfillDetails | None = None,+ *,+ use_new_events_schema: bool,) -> RecordsGenerator:"""Iterate over Arrow batch records for a batch export.@@ -263,42 +328,27 @@ def iter_records("include_events": events_to_include_array,}- start_at = dt.datetime.fromisoformat(interval_start) if interval_start is not None else None- end_at = dt.datetime.fromisoformat(interval_end)-- # TODO: this can be simplified once all backfill inputs are migrated- is_backfill = (backfill_details is not None) or is_backfill+ query = select_events_query_template(+ team_id=team_id,+ interval_start=interval_start,+ interval_end=interval_end,+ is_backfill=is_backfill,+ backfill_details=backfill_details,+ )- if start_at:- is_5_min_batch_export = (end_at - start_at) == dt.timedelta(seconds=300)- else:- is_5_min_batch_export = False+ if query is SELECT_FROM_EVENTS_VIEW:+ base_query_parameters["lookback_days"] = settings.OVERRIDE_TIMESTAMP_TEAM_IDS.get(+ team_id, settings.DEFAULT_TIMESTAMP_LOOKBACK_DAYS+ )- # for 5 min batch exports we query the events_recent table, which is known to have zero replication lag, but- # may not be able to handle the load from all batch exports- if is_5_min_batch_export and not is_backfill:- query = SELECT_FROM_EVENTS_VIEW_RECENT- # for other batch exports that should use `events_recent` we use the `distributed_events_recent` table- # which is a distributed table that sits in front of the `events_recent` table- elif use_distributed_events_recent_table(- is_backfill=is_backfill, backfill_details=backfill_details, data_interval_start=start_at- ):- query = SELECT_FROM_DISTRIBUTED_EVENTS_RECENT- elif str(team_id) in settings.UNCONSTRAINED_TIMESTAMP_TEAM_IDS:- query = SELECT_FROM_EVENTS_VIEW_UNBOUNDED- elif is_backfill:- query = SELECT_FROM_EVENTS_VIEW_BACKFILL+ if query is SELECT_FROM_EVENTS_VIEW_BACKFILL and use_new_events_schema:+ query_str = native_events_export_query(query_fields, filters_str or "", order="ORDER BY _inserted_at, event")else:- query = SELECT_FROM_EVENTS_VIEW- lookback_days = settings.OVERRIDE_TIMESTAMP_TEAM_IDS.get(team_id, settings.DEFAULT_TIMESTAMP_LOOKBACK_DAYS)- base_query_parameters["lookback_days"] = lookback_days-- if filters_str:- filters_str = f"AND {filters_str}"-- query_str = query.safe_substitute(- fields=query_fields, filters=filters_str or "", order="ORDER BY _inserted_at, event"- )+ if filters_str:+ filters_str = f"AND {filters_str}"+ query_str = query.safe_substitute(+ fields=query_fields, filters=filters_str or "", order="ORDER BY _inserted_at, event"+ )if extra_query_parameters is not None:query_parameters = base_query_parameters | extra_query_parametersdiff --git a/products/batch_exports/backend/temporal/destinations/http_batch_export.py b/products/batch_exports/backend/temporal/destinations/http_batch_export.pyindex 5fc10b7d4963..44150c7cdc04 100644--- a/products/batch_exports/backend/temporal/destinations/http_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/http_batch_export.py@@ -11,6 +11,7 @@ from structlog.contextvars import bind_contextvarsfrom temporalio import activity, workflowfrom temporalio.common import RetryPolicy+from posthog.models.event.new_events_schema import use_new_events_schemafrom posthog.sync import database_sync_to_asyncfrom posthog.temporal.common.base import PostHogWorkflowfrom posthog.temporal.common.clickhouse import get_client@@ -24,6 +25,7 @@ from products.batch_exports.backend.temporal.batch_exports import (execute_batch_export_insert_activity,get_data_interval,iter_records,+ reads_native_events_source,start_batch_export_run,)from products.batch_exports.backend.temporal.filters import compose_filters_clause@@ -34,6 +36,12 @@ from products.batch_exports.backend.temporal.utils import handle_non_retryable_eNON_RETRYABLE_ERROR_TYPES = ("NonRetryableResponseError", "InvalidDestinationURLError")LOGGER = get_logger(__name__)+_NATIVE_MUTATION_PROPERTIES = {+ "$set": "set",+ "$set_once": "set_once",+ "$unset": "unset",+ "$group_set": "group_set",+}class RetryableResponseError(Exception):@@ -74,9 +82,9 @@ async def raise_for_status(response: aiohttp.ClientResponse):raise NonRetryableResponseError(response.status, text)-def http_default_fields() -> list[BatchExportField]:+def http_default_fields(reads_native_source: bool = False) -> list[BatchExportField]:"""Return default fields used in HTTP batch export, currently supporting only migrations."""- return [+ fields = [BatchExportField(expression="uuid", alias="uuid"),BatchExportField(expression="timestamp", alias="timestamp"),BatchExportField(expression="_inserted_at", alias="_inserted_at"),@@ -85,6 +93,9 @@ def http_default_fields() -> list[BatchExportField]:BatchExportField(expression="distinct_id", alias="distinct_id"),BatchExportField(expression="elements_chain", alias="elements_chain"),]+ if reads_native_source:+ fields.extend(BatchExportField(expression=alias, alias=alias) for alias in _NATIVE_MUTATION_PROPERTIES.values())+ return fieldsclass HeartbeatDetails:@@ -200,13 +211,26 @@ async def insert_into_http_activity(inputs: HttpInsertInputs) -> BatchExportResuif inputs.batch_export_model.schema is not None:raise NotImplementedError("HTTP export does not support schemas")- fields = http_default_fields()- columns = [field["alias"] for field in fields]+ use_native_schema = await database_sync_to_async(use_new_events_schema)(inputs.team_id)interval_start = await maybe_resume_from_heartbeat(inputs)is_backfill = inputs.get_is_backfill()+ # Only the native source projects the mutation columns; a legacy table carries the same keys+ # in its `properties`.+ fields = http_default_fields(+ reads_native_events_source(+ use_new_events_schema=use_native_schema,+ team_id=inputs.team_id,+ interval_start=interval_start,+ interval_end=inputs.data_interval_end,+ is_backfill=is_backfill,+ backfill_details=inputs.backfill_details,+ )+ )+ columns = [field["alias"] for field in fields]+filters = inputs.batch_export_model.filters if inputs.batch_export_model is not None else Noneif filters is not None and len(filters) > 0:filters_str, extra_query_parameters = await database_sync_to_async(compose_filters_clause)(@@ -217,6 +241,7 @@ async def insert_into_http_activity(inputs: HttpInsertInputs) -> BatchExportResuextra_query_parameters = Nonerecord_iterator = iter_records(+ use_new_events_schema=use_native_schema,client=client,team_id=inputs.team_id,interval_start=interval_start,@@ -301,6 +326,9 @@ async def insert_into_http_activity(inputs: HttpInsertInputs) -> BatchExportResuproperties = row["properties"]properties = json.loads(properties) if properties else {}+ for property_name, column in _NATIVE_MUTATION_PROPERTIES.items():+ if value := row.get(column):+ properties[property_name] = json.loads(value)properties["$geoip_disable"] = Trueif row["event"] == "$autocapture" and row["elements_chain"] is not None:diff --git a/products/batch_exports/backend/temporal/pipeline/internal_stage.py b/products/batch_exports/backend/temporal/pipeline/internal_stage.pyindex 1138d19e0489..94c044f28ae5 100644--- a/products/batch_exports/backend/temporal/pipeline/internal_stage.py+++ b/products/batch_exports/backend/temporal/pipeline/internal_stage.py@@ -20,6 +20,7 @@ from posthog.clickhouse import query_taggingfrom posthog.clickhouse.query_tagging import Productfrom posthog.credentials import AWSKeyPairfrom posthog.dataclasses import frozen+from posthog.models.event.new_events_schema import use_new_events_schemafrom products.batch_exports.backend.temporal.utils import make_retryable_with_exponential_backoff@@ -70,6 +71,7 @@ from products.batch_exports.backend.temporal.sql.events import (EXPORT_TO_S3_FROM_EVENTS_RECENT,EXPORT_TO_S3_FROM_EVENTS_UNBOUNDED,EXPORT_TO_S3_FROM_EVENTS_WORKFLOWS,+ native_events_export_query,)from products.batch_exports.backend.temporal.sql.persons import (EXPORT_TO_S3_FROM_PERSONS,@@ -330,7 +332,9 @@ async def insert_into_internal_stage_activity(Heartbeater(),set_status_to_running_task(run_id=inputs.run_id),):- _, record_batch_model, model_name, fields, filters, extra_query_parameters = resolve_batch_exports_model(+ _, record_batch_model, model_name, fields, filters, extra_query_parameters = await database_sync_to_async(+ resolve_batch_exports_model+ )(inputs.team_id,inputs.batch_export_model,inputs.batch_export_schema,@@ -574,6 +578,13 @@ async def _get_query(else:parameters["include_events"] = []+ if "_inserted_at" not in [field["alias"] for field in fields]:+ control_fields = [BatchExportField(expression="_inserted_at", alias="_inserted_at")]+ else:+ control_fields = []++ query_fields = ",".join(f"{field['expression']} AS {field['alias']}" for field in fields + control_fields)+# for 5 min batch exports we query the events_recent table, which is known to have zero replication lag, but# may not be able to handle the load from all batch exportsif is_5_min_batch_export(full_range=full_range) and not is_backfill and not is_workflows:@@ -604,21 +615,18 @@ async def _get_query(lookback_days = settings.OVERRIDE_TIMESTAMP_TEAM_IDS.get(team_id, settings.DEFAULT_TIMESTAMP_LOOKBACK_DAYS)parameters["lookback_days"] = lookback_days- if "_inserted_at" not in [field["alias"] for field in fields]:- control_fields = [BatchExportField(expression="_inserted_at", alias="_inserted_at")]+ if query_template is EXPORT_TO_S3_FROM_EVENTS_BACKFILL and await database_sync_to_async(use_new_events_schema)(+ team_id+ ):+ query = native_events_export_query(query_fields, filters_str, s3_function=s3_function)else:- control_fields = []-- query_fields = ",".join(f"{field['expression']} AS {field['alias']}" for field in fields + control_fields)-- if filters_str:- filters_str = f"AND {filters_str}"-- query = query_template.safe_substitute(- fields=query_fields,- filters=filters_str,- s3_function=s3_function,- )+ if filters_str:+ filters_str = f"AND {filters_str}"+ query = query_template.safe_substitute(+ fields=query_fields,+ filters=filters_str,+ s3_function=s3_function,+ )parameters["team_id"] = team_id@@ -728,6 +736,8 @@ async def _write_batch_export_record_batches_to_internal_stage(# interval into sub-intervals, running one query per sub-interval, to reduce memory usageif interval_start is not None:query_parameters["interval_start"] = interval_start.strftime("%Y-%m-%d %H:%M:%S.%f")+ else:+ query_parameters["interval_start"] = Nonequery_parameters["interval_end"] = interval_end.strftime("%Y-%m-%d %H:%M:%S.%f")if isinstance(query_or_model, RecordBatchModel):diff --git a/products/batch_exports/backend/temporal/record_batch_model.py b/products/batch_exports/backend/temporal/record_batch_model.pyindex cf36270ee592..ae8ec488fa36 100644--- a/products/batch_exports/backend/temporal/record_batch_model.py+++ b/products/batch_exports/backend/temporal/record_batch_model.py@@ -3,10 +3,12 @@ import uuidimport typingimport datetime as dt+from posthog.schema import HogQLQueryModifiers, MaterializationMode, PersonsOnEventsMode+from posthog.hogql.constants import HogQLQuerySettingsfrom posthog.hogql.context import HogQLContextfrom posthog.hogql.hogql import ast-from posthog.hogql.parser import parse_expr+from posthog.hogql.parser import parse_expr, parse_selectfrom posthog.hogql.printer import prepare_ast_for_printing, print_prepared_astfrom posthog.hogql.visitor import clone_expr@@ -14,6 +16,7 @@ from posthog.clickhouse import query_taggingfrom posthog.clickhouse.query_tagging import Productfrom posthog.credentials import AWSKeyPairfrom posthog.models import Team+from posthog.models.event.new_events_schema import use_new_events_schemafrom posthog.sync import database_sync_to_asyncfrom posthog.temporal.common.clickhouse import get_clientfrom posthog.temporal.common.logger import get_write_only_logger@@ -22,6 +25,7 @@ from products.batch_exports.backend.hogql_source import (UnsupportedHogQLQueryError,create_hogql_context_for_batch_export,parse_hogql_select_for_batch_export,+ serialize_batch_export_query,)from products.batch_exports.backend.service import BatchExportModel, BatchExportSchemafrom products.batch_exports.backend.temporal.metrics import log_query_duration@@ -437,4 +441,22 @@ def resolve_batch_exports_model(fields = model["fields"] if model is not None else Nonefilters = None+ schema = batch_export_schema or (batch_export_model.schema if batch_export_model is not None else None)+ if schema is not None and (query := schema.get("hogql_query")) and use_new_events_schema(team_id):+ context = HogQLContext(+ team_id=team_id,+ enable_select_queries=True,+ limit_top_select=False,+ modifiers=HogQLQueryModifiers(+ materializationMode=MaterializationMode.DISABLED,+ personsOnEventsMode=PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS,+ ),+ )+ compiled = serialize_batch_export_query(typing.cast(ast.SelectQuery, parse_select(query)), context)+ fields = [+ {"expression": compiled_field["expression"], "alias": stored_field["alias"]}+ for stored_field, compiled_field in zip(schema["fields"], compiled["fields"], strict=True)+ ]+ extra_query_parameters = compiled["values"]+return model, record_batch_model, model_name, fields, filters, extra_query_parametersdiff --git a/products/batch_exports/backend/temporal/sql/events.py b/products/batch_exports/backend/temporal/sql/events.pyindex 34d99fb13045..a05bb249efb7 100644--- a/products/batch_exports/backend/temporal/sql/events.py+++ b/products/batch_exports/backend/temporal/sql/events.py@@ -498,3 +498,53 @@ SETTINGSmax_replica_delay_for_distributed_queries=1,optimize_aggregation_in_order=1"""+++# The `{{}}` literals below are not a typo. `ClickHouseClient.prepare_query` runs `str.format` over+# the whole query, which turns `{{}}` back into `{}`. A bare `{}` would parse as a positional field+# and reach ClickHouse as `{0}`, so the `nullIf` would never match an empty object.+SERIALIZED_EVENTS_JSON_SOURCE = """(+ SELECT * REPLACE (+ toString(uuid) AS uuid,+ toString(person_id) AS person_id,+ JSONStripEmptyStringsAndNulls(toJSONString(properties)) AS properties,+ JSONStripEmptyStringsAndNulls(toJSONString(person_properties)) AS person_properties+ ),+ nullIf(toJSONString(temporary_properties.^`$set`), '{{}}') AS set,+ nullIf(toJSONString(temporary_properties.^`$set_once`), '{{}}') AS set_once,+ nullIf(toJSONString(temporary_properties.^`$unset`), '[]') AS unset,+ nullIf(toJSONString(temporary_properties.^`$group_set`), '{{}}') AS group_set+ FROM events_json+)"""+++def native_events_export_query(+ fields: str,+ filters: str = "",+ *,+ order: str = "",+ s3_function: str | None = None,+) -> str:+ return f"""+{"INSERT INTO FUNCTION " + s3_function if s3_function else ""}+SELECT {fields}+FROM (+ SELECT DISTINCT ON (team_id, event, cityHash64(events.distinct_id), cityHash64(events.uuid))+ *, timestamp AS _inserted_at+ FROM {SERIALIZED_EVENTS_JSON_SOURCE} AS events+ WHERE team_id = {{{{team_id:Int64}}}}+ AND ({{interval_start}}::Nullable(DateTime64) IS NULL OR timestamp >= {{interval_start}}::Nullable(DateTime64))+ AND timestamp < {{{{interval_end:DateTime64}}}}+ AND (length({{{{include_events:Array(String)}}}}) = 0 OR event IN {{{{include_events:Array(String)}}}})+ AND (length({{{{exclude_events:Array(String)}}}}) = 0 OR event NOT IN {{{{exclude_events:Array(String)}}}})+ {"AND " + filters if filters else ""}+ {order}+) AS events+{"" if s3_function else "FORMAT ArrowStream"}+SETTINGS+ max_bytes_before_external_sort=50000000000,+ max_replica_delay_for_distributed_queries=60,+ fallback_to_stale_replicas_for_distributed_queries=0,+ optimize_aggregation_in_order=1+{", log_comment={log_comment}" if s3_function else ""}+"""diff --git a/products/batch_exports/backend/tests/api/test_serializers.py b/products/batch_exports/backend/tests/api/test_serializers.pyindex c3052fd3f1f2..095fa5d5785a 100644--- a/products/batch_exports/backend/tests/api/test_serializers.py+++ b/products/batch_exports/backend/tests/api/test_serializers.py@@ -1,46 +1,57 @@+from types import SimpleNamespacefrom typing import cast-from posthog.test.base import BaseTest+from posthog.test.base import BaseTest, materialized+from unittest.mock import patch-from parameterized import parameterized+from django.test import override_settings-from posthog.schema import HogQLQueryModifiers, PersonsOnEventsMode+from parameterized import parameterized+from rest_framework import serializersfrom posthog.hogql import ast-from posthog.hogql.hogql import HogQLContext-from posthog.hogql.parser import parse_select-from posthog.hogql.printer import prepare_ast_for_printing+from posthog.hogql.property_access_types import RestrictedPropertyfrom posthog.api.scoped_related_fields import TeamScopedPrimaryKeyRelatedField-from posthog.models import Organization, Team+from posthog.models import Organization, PropertyDefinition, Teamfrom posthog.models.integration import Integration-from products.batch_exports.backend.api.batch_export import BatchExportDestinationSerializer, BatchExportSerializer+from products.batch_exports.backend.api.batch_export import (+ BatchExportDestinationSerializer,+ BatchExportSerializer,+ HogQLSelectQueryField,+)def prepare_query(query: str, team_id: int) -> ast.SelectQuery:"""Parse and resolve a HogQL query string into a prepared AST."""- parsed = parse_select(query)- return cast(- ast.SelectQuery,- prepare_ast_for_printing(- parsed,- context=HogQLContext(- team_id=team_id,- enable_select_queries=True,- modifiers=HogQLQueryModifiers(- personsOnEventsMode=PersonsOnEventsMode.PERSON_ID_NO_OVERRIDE_PROPERTIES_ON_EVENTS- ),- ),- dialect="clickhouse",- ),- )+ serializer = BatchExportSerializer(context={"team_id": team_id, "request": SimpleNamespace(user=None)})+ field = HogQLSelectQueryField()+ field.bind("hogql_query", serializer)+ return cast(ast.SelectQuery, field.to_internal_value(query))class TestSerializeHogQLQueryToBatchExportSchema(BaseTest):def _make_serializer(self) -> BatchExportSerializer:return BatchExportSerializer(context={"team_id": self.team.pk})+ @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=False)+ def test_resaving_legacy_query_preserves_types_and_column_names(self):+ PropertyDefinition.objects.create(+ team=self.team, name="amount", type=PropertyDefinition.Type.EVENT, property_type="Numeric"+ )+ query = "SELECT round(e.properties.amount) AS rounded, lower(e.event) FROM events AS e"+ serializer = self._make_serializer()++ schema = serializer.serialize_hogql_query_to_batch_export_schema(prepare_query(query, self.team.pk))+ resaved = serializer.serialize_hogql_query_to_batch_export_schema(prepare_query(query, self.team.pk))++ assert schema == resaved+ assert [field["alias"] for field in schema["fields"]] == ["rounded", "`lower(e.event)`"]+ assert schema["fields"][0]["expression"].startswith("round(accurateCastOrNull(")+ assert schema["values"] == {"hogql_val_0": "amount", "hogql_val_1": "Float64"}+ assert "toFloat(" in schema["hogql_query"]+@parameterized.expand([(@@ -135,6 +146,72 @@ class TestSerializeHogQLQueryToBatchExportSchema(BaseTest):assert field["alias"] == "`x, (SELECT query FROM another_table LIMIT 100) AS leaked`"assert field["expression"] == "events.uuid"+ @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)+ def test_native_query_keeps_property_type_casts(self):+ PropertyDefinition.objects.create(+ team=self.team, name="amount", type=PropertyDefinition.Type.EVENT, property_type="Numeric"+ )+ query = "SELECT e.properties.amount AS amount FROM events AS e"++ schema = self._make_serializer().serialize_hogql_query_to_batch_export_schema(+ prepare_query(query, self.team.pk)+ )++ assert schema["fields"][0]["expression"].startswith("accurateCastOrNull(")+ assert schema["values"]["hogql_val_1"] == "Float64"++ @parameterized.expand([("unrestricted", False), ("restricted", True)])+ @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=False)+ def test_materialized_columns_are_kept_out_of_a_query_that_cannot_be_recompiled(self, _name: str, restricted: bool):+ restrictions = (+ {RestrictedProperty(name="secret", property_type=PropertyDefinition.Type.EVENT)} if restricted else set()+ )+ with (+ patch(+ "products.batch_exports.backend.api.batch_export."+ "get_restricted_properties_with_group_type_index_for_team",+ return_value=restrictions,+ ),+ materialized("events", "$browser"),+ ):+ query = prepare_query("SELECT properties.$browser AS browser FROM events", self.team.pk)+ serializer = BatchExportSerializer(+ context={"team_id": self.team.pk, "request": SimpleNamespace(user=self.user)}+ )++ schema = serializer.serialize_hogql_query_to_batch_export_schema(query)++ expression = schema["fields"][0]["expression"]+ if restricted:+ assert "hogql_query" not in schema+ assert "mat_" not in expression+ else:+ assert "mat_$browser" in expression++ @override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)+ @patch("products.batch_exports.backend.api.batch_export.get_restricted_properties_with_group_type_index_for_team")+ @patch("posthog.models.event.new_events_schema.use_new_events_schema", return_value=True)+ def test_restricted_property_query_is_not_recompiled_without_user(+ self, _use_new_events_schema, get_restricted_properties+ ):+ get_restricted_properties.return_value = {+ RestrictedProperty(name="secret", property_type=PropertyDefinition.Type.EVENT)+ }+ query = prepare_query("SELECT properties.secret AS secret FROM events", self.team.pk)+ serializer = BatchExportSerializer(+ context={"team_id": self.team.pk, "request": SimpleNamespace(user=self.user)}+ )++ schema = serializer.serialize_hogql_query_to_batch_export_schema(query)++ assert schema["fields"] == [{"expression": "NULL", "alias": "secret"}]+ assert "hogql_query" not in schema++ with self.assertRaises(serializers.ValidationError):+ serializer.serialize_hogql_query_to_batch_export_schema(+ prepare_query("SELECT properties FROM events", self.team.pk)+ )+class TestBatchExportDestinationSerializerTeamScoping(BaseTest):def _make_integration(self, team: Team) -> Integration:diff --git a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.pyindex 7fcfc84ff3d2..be6701cd151b 100644--- a/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py+++ b/products/batch_exports/backend/tests/temporal/destinations/file_download/test_file_download_api.py@@ -20,8 +20,9 @@ from rest_framework import statusfrom temporalio.worker import UnsandboxedWorkflowRunner, Workerfrom posthog.exceptions import ClickHouseQueryTimeOut+from posthog.models.event.util import bulk_create_eventsfrom posthog.models.scoping import team_scope-from posthog.temporal.tests.utils.events import generate_test_events, insert_event_values_in_clickhouse+from posthog.temporal.tests.utils.events import generate_test_eventsfrom products.batch_exports.backend.api.file_download import (COUNT_ROWS_TIMEOUT_MESSAGE,@@ -630,7 +631,7 @@ class TestFileDownloadHogQL:yield@pytest.fixture- async def hogql_export_test_events(self, clickhouse_client, team):+ async def hogql_export_test_events(self, clickhouse_client, team, truncate_clickhouse_tables):"""Insert events for this and another team directly into the events table.A hogql export reads the main (sharded) events table with no interval filter, so@@ -652,8 +653,11 @@ class TestFileDownloadHogQL:event_name="test-{i}",properties={"$browser": "Chrome"},)- await insert_event_values_in_clickhouse(- client=clickhouse_client, events=events + events_from_other_team, table="sharded_events"+ await sync_to_async(bulk_create_events)(+ [+ {**event, "event_uuid": event["uuid"], "person_properties": event["person_properties"] or {}}+ for event in events + events_from_other_team+ ])return eventsdiff --git a/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.pyindex c64dad4a3c94..ce0a81d7c1b2 100644--- a/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.py+++ b/products/batch_exports/backend/tests/temporal/destinations/test_http_batch_export_workflow.py@@ -10,6 +10,7 @@ import unittest.mockfrom django.conf import settingsfrom django.test import override_settings+import pyarrow as paimport pytest_asynciofrom aioresponses import aioresponsesfrom temporalio import activity@@ -95,6 +96,7 @@ async def assert_clickhouse_records_in_mock_server(expected_records = []for records in iter_records(+ use_new_events_schema=False,client=clickhouse_client,team_id=team_id,interval_start=data_interval_start.isoformat(),@@ -234,6 +236,120 @@ async def test_insert_into_http_activity_inserts_data_into_http_endpoint()+async def test_insert_into_http_activity_preserves_mutation_properties_when_using_native_events(+ activity_environment, http_config+):+ """Native ingestion strips the mutation keys out of `properties`, so the export has to put them+ back from the columns the native source carries.+ """+ interval_end = dt.datetime(2026, 1, 2, tzinfo=dt.UTC)+ event_time = interval_end - dt.timedelta(hours=1)+ record_batch = pa.RecordBatch.from_pylist(+ [+ {+ "uuid": str(uuid4()),+ "timestamp": event_time,+ "_inserted_at": event_time,+ "event": "$pageview",+ "properties": "{}",+ "distinct_id": "person-1",+ "elements_chain": None,+ "set": '{"email":"[email protected]"}',+ "set_once": '{"first_seen":"2026-01-01"}',+ "unset": '["old_property"]',+ "group_set": '{"company":{"name":"Example"}}',+ }+ ]+ )+ insert_inputs = HttpInsertInputs(+ team_id=randint(1, 1000000),+ data_interval_start=None,+ data_interval_end=interval_end.isoformat(),+ batch_export_schema=None,+ backfill_details=BackfillDetails(+ backfill_id=None,+ start_at=None,+ end_at=interval_end.isoformat(),+ ),+ **http_config,+ )+ mock_server = MockServer()++ with (+ unittest.mock.patch(+ "products.batch_exports.backend.temporal.destinations.http_batch_export.use_new_events_schema",+ return_value=True,+ ),+ unittest.mock.patch(+ "products.batch_exports.backend.temporal.destinations.http_batch_export.iter_records",+ return_value=iter([record_batch]),+ ),+ aioresponses(passthrough=[settings.CLICKHOUSE_HTTP_URL]) as responses,+ ):+ responses.post(TEST_URL, status=200, callback=mock_server.post, repeat=True)+ await activity_environment.run(insert_into_http_activity, insert_inputs)++ assert mock_server.records[0]["properties"] == {+ "$geoip_disable": True,+ "$set": {"email": "[email protected]"},+ "$set_once": {"first_seen": "2026-01-01"},+ "$unset": ["old_property"],+ "$group_set": {"company": {"name": "Example"}},+ }++[email protected]("is_backfill", [False, True], ids=["scheduled", "backfill"])+async def test_insert_into_http_activity_exports_mutation_properties_from_legacy_table(+ clickhouse_client, activity_environment, http_config, is_backfill+):+ """A recent interval reads a legacy table even on the native schema, and those tables project no+ mutation columns. The keys come from `properties`, which a legacy table still carries.+ """+ team_id = randint(1, 1000000)+ interval_end = dt.datetime.now(tz=dt.UTC).replace(microsecond=0) - dt.timedelta(hours=1)+ interval_start = interval_end - dt.timedelta(hours=1)+ await generate_test_events_in_clickhouse(+ client=clickhouse_client,+ team_id=team_id,+ start_time=interval_start,+ end_time=interval_end,+ count=1,+ count_outside_range=0,+ count_other_team=0,+ properties={"$browser": "Chrome", "$set": {"email": "[email protected]"}, "$unset": ["old_property"]},+ inserted_at=interval_start,+ table="events_recent",+ )+ insert_inputs = HttpInsertInputs(+ team_id=team_id,+ data_interval_start=interval_start.isoformat(),+ data_interval_end=interval_end.isoformat(),+ batch_export_schema=None,+ backfill_details=(+ BackfillDetails(backfill_id=None, start_at=interval_start.isoformat(), end_at=interval_end.isoformat())+ if is_backfill+ else None+ ),+ **http_config,+ )+ mock_server = MockServer()++ with (+ unittest.mock.patch(+ "products.batch_exports.backend.temporal.destinations.http_batch_export.use_new_events_schema",+ return_value=True,+ ),+ aioresponses(passthrough=[settings.CLICKHOUSE_HTTP_URL]) as responses,+ ):+ responses.post(TEST_URL, status=200, callback=mock_server.post, repeat=True)+ result = await activity_environment.run(insert_into_http_activity, insert_inputs)++ assert result.records_completed == 1+ [exported] = mock_server.records+ assert exported["properties"]["$set"] == {"email": "[email protected]"}+ assert exported["properties"]["$unset"] == ["old_property"]++async def test_insert_into_http_activity_throws_on_bad_http_status(clickhouse_client, activity_environment, http_config, exclude_events):diff --git a/products/batch_exports/backend/tests/temporal/pipeline/test_internal_stage.py b/products/batch_exports/backend/tests/temporal/pipeline/test_internal_stage.pyindex f5368123264f..eb6d7061c0a7 100644--- a/products/batch_exports/backend/tests/temporal/pipeline/test_internal_stage.py+++ b/products/batch_exports/backend/tests/temporal/pipeline/test_internal_stage.py@@ -71,6 +71,7 @@ def mock_clickhouse_client():yield mock_client[email protected]("use_native_schema", [False, True])@pytest.mark.parametrize("interval", ["day", "every 5 minutes"], indirect=True)@pytest.mark.parametrize("model",@@ -91,6 +92,7 @@ async def test_insert_into_stage_activity_executes_the_expected_query_for_eventsmodel: BatchExportModel,is_backfill: bool,backfill_within_last_6_days: bool,+ use_native_schema: bool,):"""Test that the insert_into_internal_stage_activity executes the expected ClickHouse query when the model is an events model.@@ -107,7 +109,7 @@ async def test_insert_into_stage_activity_executes_the_expected_query_for_eventsif not is_backfill and interval == "every 5 minutes":expected_table = "events_recent"elif is_backfill and not backfill_within_last_6_days:- expected_table = "events"+ expected_table = "events_json" if use_native_schema else "events"if backfill_within_last_6_days:backfill_start_at = (data_interval_end - dt.timedelta(days=3)).isoformat()@@ -138,7 +140,8 @@ async def test_insert_into_stage_activity_executes_the_expected_query_for_eventsdestination_default_fields=None,)- await activity_environment.run(insert_into_internal_stage_activity, insert_inputs)+ with override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=use_native_schema):+ await activity_environment.run(insert_into_internal_stage_activity, insert_inputs)mock_clickhouse_client.expect_select_from_table(expected_table)mock_clickhouse_client.expect_properties_in_log_comment({diff --git a/products/batch_exports/backend/tests/temporal/test_batch_exports.py b/products/batch_exports/backend/tests/temporal/test_batch_exports.pyindex b04fb0efba1e..3d51e75c454f 100644--- a/products/batch_exports/backend/tests/temporal/test_batch_exports.py+++ b/products/batch_exports/backend/tests/temporal/test_batch_exports.py@@ -9,7 +9,13 @@ from django.test import override_settingsfrom posthog.temporal.tests.utils.events import generate_test_events_in_clickhouse-from products.batch_exports.backend.temporal.batch_exports import DataInterval, get_data_interval, iter_records+from products.batch_exports.backend.service import BackfillDetails+from products.batch_exports.backend.temporal.batch_exports import (+ DataInterval,+ get_data_interval,+ iter_records,+ reads_native_events_source,+)pytestmark = [pytest.mark.asyncio, pytest.mark.django_db]@@ -45,11 +51,13 @@ def assert_records_match_events(records, events):assert value == expected[key]-async def test_iter_records(clickhouse_client):[email protected]("use_native_schema", [False, True])[email protected]("interval_minutes", [5, 60])+async def test_iter_records(clickhouse_client, use_native_schema, interval_minutes):"""Test the rows returned by iter_records."""team_id = randint(1, 1000000)data_interval_end = dt.datetime.now(tz=dt.UTC).replace(hour=0, minute=0, second=0, microsecond=0)- data_interval_start = data_interval_end - dt.timedelta(hours=1)+ data_interval_start = data_interval_end - dt.timedelta(minutes=interval_minutes)(events, _, _) = await generate_test_events_in_clickhouse(client=clickhouse_client,@@ -70,6 +78,7 @@ async def test_iter_records(clickhouse_client):team_id,data_interval_start.isoformat(),data_interval_end.isoformat(),+ use_new_events_schema=use_native_schema,)for record in record_batch.to_pylist()]@@ -102,6 +111,7 @@ async def test_iter_records_handles_duplicates(clickhouse_client):team_id,data_interval_start.isoformat(),data_interval_end.isoformat(),+ use_new_events_schema=False,)for record in record_batch.to_pylist()]@@ -137,6 +147,7 @@ async def test_iter_records_can_exclude_events(clickhouse_client):data_interval_start.isoformat(),data_interval_end.isoformat(),exclude_events=exclude_events,+ use_new_events_schema=False,)for record in record_batch.to_pylist()]@@ -172,6 +183,7 @@ async def test_iter_records_can_include_events(clickhouse_client):data_interval_start.isoformat(),data_interval_end.isoformat(),include_events=include_events,+ use_new_events_schema=False,)for record in record_batch.to_pylist()]@@ -211,6 +223,7 @@ async def test_iter_records_ignores_timestamp_predicates(clickhouse_client):team_id,inserted_at.isoformat(),data_interval_end.isoformat(),+ use_new_events_schema=False,)for record in record_batch.to_pylist()]@@ -225,6 +238,7 @@ async def test_iter_records_ignores_timestamp_predicates(clickhouse_client):team_id,inserted_at.isoformat(),data_interval_end.isoformat(),+ use_new_events_schema=False,)for record in record_batch.to_pylist()]@@ -263,6 +277,7 @@ async def test_iter_records_can_flatten_properties(clickhouse_client):{"expression": "JSONExtractString(properties, '$os')", "alias": "os"},{"expression": "JSONExtractInt(properties, 'custom-property')", "alias": "custom_prop"},],+ use_new_events_schema=False,)for record in record_batch.to_pylist()]@@ -308,6 +323,7 @@ async def test_iter_records_uses_extra_query_parameters(clickhouse_client):{"expression": "JSONExtractInt(properties, %(hogql_val_0)s)", "alias": "custom_prop"},],extra_query_parameters={"hogql_val_0": "custom"},+ use_new_events_schema=False,)for record in record_batch.to_pylist()]@@ -390,3 +406,33 @@ def test_data_interval_rejects_reversed_bounds() -> None:end = dt.datetime(2023, 8, 1, tzinfo=dt.UTC)with pytest.raises(ValueError, match="start"):DataInterval(start=end + dt.timedelta(seconds=1), end=end)+++ "start_ago,end_ago,is_backfill,backfill_ago,expected",+ [+ (dt.timedelta(hours=2), dt.timedelta(hours=1), False, None, False),+ (dt.timedelta(days=61), dt.timedelta(days=60), False, None, False),+ (dt.timedelta(days=61), dt.timedelta(days=60), True, dt.timedelta(days=61), True),+ (dt.timedelta(hours=2), dt.timedelta(hours=1), True, dt.timedelta(hours=2), False),+ ],+ ids=["scheduled-recent", "scheduled-old", "backfill-old", "backfill-recent"],+)+def test_reads_native_events_source_tracks_query_routing(start_ago, end_ago, is_backfill, backfill_ago, expected):+ now = dt.datetime.now(tz=dt.UTC)+ start, end = now - start_ago, now - end_ago+ backfill_details = (+ BackfillDetails(backfill_id=None, start_at=(now - backfill_ago).isoformat(), end_at=end.isoformat())+ if backfill_ago is not None+ else None+ )+ arguments = {+ "team_id": 1,+ "interval_start": start.isoformat(),+ "interval_end": end.isoformat(),+ "is_backfill": is_backfill,+ "backfill_details": backfill_details,+ }++ assert reads_native_events_source(use_new_events_schema=True, **arguments) is expected+ assert reads_native_events_source(use_new_events_schema=False, **arguments) is Falsediff --git a/products/batch_exports/backend/tests/temporal/test_events_sql.py b/products/batch_exports/backend/tests/temporal/test_events_sql.pynew file mode 100644index 000000000000..b30253772667--- /dev/null+++ b/products/batch_exports/backend/tests/temporal/test_events_sql.py@@ -0,0 +1,26 @@+from posthog.temporal.common.clickhouse import ClickHouseClient++from products.batch_exports.backend.temporal.sql.events import native_events_export_query++QUERY_PARAMETERS: dict[str, object] = {+ "team_id": 1,+ "interval_start": None,+ "interval_end": "2026-01-01 00:00:00",+ "include_events": [],+ "exclude_events": [],+}+++def test_native_events_export_query_refuses_stale_replicas() -> None:+ query = native_events_export_query("event")++ assert "max_replica_delay_for_distributed_queries=60" in query+ assert "fallback_to_stale_replicas_for_distributed_queries=0" in query+++def test_native_events_export_query_keeps_empty_object_literals() -> None:+ query = ClickHouseClient().prepare_query(native_events_export_query("event"), QUERY_PARAMETERS)++ assert "'{0}'" not in query+ for key in ("$set", "$set_once", "$group_set"):+ assert f"temporary_properties.^`{key}`), '{{}}')" in querydiff --git a/products/batch_exports/backend/tests/temporal/test_filters.py b/products/batch_exports/backend/tests/temporal/test_filters.pyindex e04ea0460a54..d3fb7d454120 100644--- a/products/batch_exports/backend/tests/temporal/test_filters.py+++ b/products/batch_exports/backend/tests/temporal/test_filters.py@@ -4,6 +4,12 @@ import typingimport pytest+from django.test import override_settings++from posthog.clickhouse.client import sync_execute+from posthog.models import PropertyDefinition+from posthog.sync import database_sync_to_async+from products.batch_exports.backend.temporal.filters import InvalidFilterError, compose_filters_clausepytestmark = [pytest.mark.asyncio, pytest.mark.django_db]@@ -119,6 +125,32 @@ def test_compose_filters_clause_uses_legacy_events_schema(settings, ateam):assert result_values == {"hogql_val_0": "$browser", "hogql_val_1": "Chrome"}+ "property_type,document,predicate",+ [+ ("Numeric", '{"value":2.5}', "properties.value > 2"),+ ("Numeric", '{"value":2.5}', "round(properties.value) = 2"),+ ("Boolean", '{"value":true}', "properties.value = true"),+ ],+)[email protected]("use_new_events_schema", [False, True])+async def test_filters_preserve_property_types(ateam, property_type, document, predicate, use_new_events_schema):+ await database_sync_to_async(PropertyDefinition.objects.create)(+ team=ateam, name="value", type=PropertyDefinition.Type.EVENT, property_type=property_type+ )+ with override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=use_new_events_schema):+ clause, values = await database_sync_to_async(compose_filters_clause)(+ [{"key": predicate, "type": "hogql"}], team_id=ateam.id+ )++ result = await database_sync_to_async(sync_execute)(+ f"SELECT {clause} FROM (SELECT %(document)s AS properties) AS events",+ {**values, "document": document},+ )++ assert result == [(1,)]++@pytest.mark.parametrize("filters",(diff --git a/products/batch_exports/backend/tests/temporal/test_record_batch_model.py b/products/batch_exports/backend/tests/temporal/test_record_batch_model.pyindex fbf26633d8c1..adcffb72dd68 100644--- a/products/batch_exports/backend/tests/temporal/test_record_batch_model.py+++ b/products/batch_exports/backend/tests/temporal/test_record_batch_model.py@@ -1,19 +1,27 @@+import jsonimport datetime as dtimport pytest+from django.conf import settingsfrom django.test import override_settings+import pyarrow as pa+from posthog.hogql.hogql import astfrom posthog.hogql.printer import prepare_ast_for_printing, print_prepared_astfrom posthog.credentials import AWSKeyPair+from posthog.models.event.sql import EVENTS_PROPERTIES_JSON_TYPE, PERSON_PROPERTIES_JSON_TYPEfrom posthog.models.utils import uuid7from posthog.sync import database_sync_to_async+from posthog.temporal.common.clickhouse import ClickHouseClientfrom posthog.temporal.tests.utils.events import generate_test_events_in_clickhousefrom products.batch_exports.backend.hogql_source import UnsupportedHogQLQueryError-from products.batch_exports.backend.service import BatchExportModel+from products.batch_exports.backend.service import BatchExportModel, BatchExportSchema+from products.batch_exports.backend.temporal.batch_exports import iter_records+from products.batch_exports.backend.temporal.filters import compose_filters_clausefrom products.batch_exports.backend.temporal.record_batch_model import (HogQLQueryRecordBatchModel,SessionsRecordBatchModel,@@ -451,3 +459,118 @@ class TestHogQLQueryRecordBatchModel:"""Without this, a missing query would fall through to the events template path and export the wrong data."""with pytest.raises(UnsupportedHogQLQueryError):resolve_batch_exports_model(team_id=1, batch_export_model=BatchExportModel(name="hogql", schema=None))++[email protected]("use_new_events_schema", [False, True])+async def test_custom_export_recompilation_preserves_column_names(ateam, use_new_events_schema):+ schema: BatchExportSchema = {+ "hogql_query": "SELECT lower(e.event), e.properties.$browser AS browser FROM events AS e",+ "fields": [+ {"expression": "lower(e.event)", "alias": "`lower(e.event)`"},+ {"expression": "events.mat_removed_column", "alias": "browser"},+ ],+ "values": {"unused_old_parameter": "stale"},+ }+ with override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=use_new_events_schema):+ _, _, _, fields, _, values = await database_sync_to_async(resolve_batch_exports_model)(+ team_id=ateam.pk, batch_export_schema=schema+ )++ assert fields is not None+ assert [field["alias"] for field in fields] == ["`lower(e.event)`", "browser"]+ if use_new_events_schema:+ assert fields[0]["expression"] == "lower(events.event)"+ assert "mat_removed_column" not in fields[1]["expression"]+ assert values == {"hogql_val_0": "$browser"}+ else:+ assert fields == schema["fields"]+ assert values == schema["values"]+ assert schema["fields"][0]["expression"] == "lower(e.event)"++[email protected]("interval_start_is_none", [False, True])+@override_settings(CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA=True)+async def test_custom_export_backfill_runs_without_legacy_events_tables(+ ateam, clickhouse_client, interval_start_is_none+):+ database = f"native_export_{uuid7().hex}"+ await clickhouse_client.execute_query(f"CREATE DATABASE {database}")+ try:+ async with ClickHouseClient(+ url=settings.CLICKHOUSE_HTTP_URL,+ user=settings.CLICKHOUSE_USER,+ password=settings.CLICKHOUSE_PASSWORD,+ database=database,+ output_format_arrow_string_as_string="true",+ ) as client:+ await client.execute_query(+ f"CREATE TABLE events_json (uuid UUID, person_id UUID, team_id Int64, event String, distinct_id String, "+ f"timestamp DateTime64(6), inserted_at DateTime64(6), created_at DateTime64(6), elements_chain String, "+ f"properties {EVENTS_PROPERTIES_JSON_TYPE()}, person_properties {PERSON_PROPERTIES_JSON_TYPE()}, "+ "temporary_properties JSON) ENGINE = Memory"+ )+ row = {+ "uuid": str(uuid7()),+ "person_id": str(uuid7()),+ "team_id": ateam.pk,+ "event": "purchase",+ "distinct_id": "buyer",+ "timestamp": "2024-01-01 12:00:00",+ "inserted_at": "2024-02-01 12:00:00",+ "created_at": "2024-02-01 12:00:00",+ "elements_chain": "",+ "properties": {"$browser": "Firefox", "amount": 2.5, "person": {"properties": "event value"}},+ "person_properties": {"email": "[email protected]"},+ "temporary_properties": {"$set": {"email": "[email protected]"}},+ }+ await client.execute_query(+ "INSERT INTO events_json FORMAT JSONEachRow\n"+ + "\n".join(json.dumps(value) for value in [row, row, {**row, "team_id": ateam.pk + 1}])+ )+ schema: BatchExportSchema = {+ "hogql_query": "SELECT e.properties.$browser AS browser, e.properties.amount AS amount, e.person.properties.email AS email, e.properties.person.properties AS nested FROM events AS e",+ "fields": [+ {"expression": "events.mat_removed_column", "alias": alias}+ for alias in ("browser", "amount", "email", "nested")+ ],+ "values": {"unused_old_parameter": "stale"},+ }+ _, _, _, fields, _, values = await database_sync_to_async(resolve_batch_exports_model)(+ team_id=ateam.pk, batch_export_schema=schema+ )+ assert fields is not None+ assert "unused_old_parameter" not in values+ predicate, values = await database_sync_to_async(compose_filters_clause)(+ [{"key": "$browser", "type": "event", "operator": "exact", "value": ["Firefox"]}],+ team_id=ateam.pk,+ values=values,+ )+ batches: list[pa.RecordBatch] = await database_sync_to_async(+ lambda: list(+ iter_records(+ client=client,+ team_id=ateam.pk,+ use_new_events_schema=True,+ interval_start=None if interval_start_is_none else "2024-01-01 00:00:00",+ interval_end="2024-01-02 00:00:00",+ include_events=["purchase"],+ fields=fields+ + [{"expression": key, "alias": key} for key in ("properties", "person_properties", "set")],+ filters_str=predicate,+ extra_query_parameters=values,+ is_backfill=True,+ )+ )+ )()+ rows = pa.Table.from_batches(batches).to_pylist()+ assert len(rows) == 1+ assert rows[0]["browser"] == "Firefox"+ assert rows[0]["amount"] == "2.5"+ assert rows[0]["email"] == "[email protected]"+ assert rows[0]["nested"] == "event value"+ assert json.loads(rows[0]["properties"])["$browser"] == "Firefox"+ assert json.loads(rows[0]["person_properties"])["email"] == "[email protected]"+ assert json.loads(rows[0]["set"]) == {"email": "[email protected]"}+ assert rows[0]["_inserted_at"] == dt.datetime(2024, 1, 1, 12, tzinfo=dt.UTC)+ finally:+ await clickhouse_client.execute_query(f"DROP DATABASE {database}")diff --git a/products/batch_exports/backend/tests/temporal/utils/clickhouse.py b/products/batch_exports/backend/tests/temporal/utils/clickhouse.pyindex e3fd1ae0f69e..ca4daf14b800 100644--- a/products/batch_exports/backend/tests/temporal/utils/clickhouse.py+++ b/products/batch_exports/backend/tests/temporal/utils/clickhouse.py@@ -72,6 +72,7 @@ async def create_clickhouse_tables_and_views(clickhouse_client):async def truncate_events(clickhouse_client):await execute_query(clickhouse_client, "TRUNCATE TABLE IF EXISTS sharded_events")+ await execute_query(clickhouse_client, "TRUNCATE TABLE IF EXISTS sharded_events_json")await execute_query(clickhouse_client, "TRUNCATE TABLE IF EXISTS distributed_events_recent")await execute_query(clickhouse_client, "TRUNCATE TABLE IF EXISTS events_recent")await execute_query(clickhouse_client, "TRUNCATE TABLE IF EXISTS sharded_events_recent")diff --git a/products/data_warehouse/backend/tests/api/test_expression.py b/products/data_warehouse/backend/tests/api/test_expression.pyindex 44aa56a3193b..48a1c6d5993e 100644--- a/products/data_warehouse/backend/tests/api/test_expression.py+++ b/products/data_warehouse/backend/tests/api/test_expression.py@@ -50,8 +50,11 @@ class TestExpressionApi(APIBaseTest):context = HogQLContext(team_id=self.team.pk, database=database, enable_select_queries=True)printed, _ = prepare_and_print_ast(parse_select("SELECT browser FROM events"), context, "clickhouse")- self.assertIn("JSONExtractRaw(events.properties", printed)- self.assertIn("$browser", context.values.values())+ if context.uses_new_events_schema():+ self.assertIn("nullIf(events.properties.`$browser`, '') AS browser", printed)+ else:+ self.assertIn("JSONExtractRaw(events.properties", printed)+ self.assertIn("$browser", context.values.values())@parameterized.expand([diff --git a/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.py b/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.pyindex d98057528bf1..179162b4c235 100644--- a/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.py+++ b/products/error_tracking/backend/hogql_queries/error_tracking_query_builder.py@@ -886,18 +886,15 @@ class ErrorTrackingQueryBuilder:for property_name in properties:# A property definition can type a searched property as# Boolean, Float, or DateTime, and the property swapper then- # casts the field away from String. `lower()` rejects those+ # casts the field away from String. String search rejects those# types, so stringify first.field = ast.Call(name="toString", args=[ast.Field(chain=[*chain_prefix, property_name])])or_exprs.append(ast.CompareOperation(op=ast.CompareOperationOp.Gt,left=ast.Call(- name="position",- args=[- ast.Call(name="lower", args=[field]),- ast.Call(name="lower", args=[ast.Constant(value=token)]),- ],+ name="multiSearchAnyCaseInsensitive",+ args=[field, ast.Array(exprs=[ast.Constant(value=token)])],),right=ast.Constant(value=0),)diff --git a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambrindex 1e678b3042e3..e0b2784f2403 100644--- a/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr+++ b/products/error_tracking/backend/hogql_queries/test/__snapshots__/test_error_tracking_query_runner.ambr@@ -150,7 +150,7 @@argMaxState(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources', -1), ''), 'null'), '^"|"$', ''), toTimeZone(e.timestamp, 'UTC')) AS source_state,argMaxState(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$lib'), ''), 'null'), '^"|"$', ''), toTimeZone(e.timestamp, 'UTC')) AS library_stateFROM events AS e- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null'))), lower('probs')), 0), 0), ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null'))), lower('probs')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', ''))), lower('probs')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', ''))), lower('probs')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('probs')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('probs')), 0), 0)), or(ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null'))), lower('not')), 0), 0), ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null'))), lower('not')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', ''))), lower('not')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', ''))), lower('not')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('not')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('not')), 0), 0)), or(ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null'))), lower('found')), 0), 0), ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null'))), lower('found')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', ''))), lower('found')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', ''))), lower('found')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('found')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('found')), 0), 0))))+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null')), ['probs']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null')), ['probs']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', '')), ['probs']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', '')), ['probs']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', '')), ['probs']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), ['probs']), 0), 0)), or(ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null')), ['not']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null')), ['not']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', '')), ['not']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', '')), ['not']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', '')), ['not']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), ['not']), 0), 0)), or(ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null')), ['found']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null')), ['found']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', '')), ['found']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', '')), ['found']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', '')), ['found']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), ['found']), 0), 0))))GROUP BY fp_hash) AS evINNER JOIN(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,@@ -978,7 +978,7 @@argMaxState(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources', -1), ''), 'null'), '^"|"$', ''), toTimeZone(e.timestamp, 'UTC')) AS source_state,argMaxState(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$lib'), ''), 'null'), '^"|"$', ''), toTimeZone(e.timestamp, 'UTC')) AS library_stateFROM events AS e- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null'))), lower('[email protected]')), 0), 0), ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null'))), lower('[email protected]')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', ''))), lower('[email protected]')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', ''))), lower('[email protected]')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('[email protected]')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('[email protected]')), 0), 0)))+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null')), ['[email protected]']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null')), ['[email protected]']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', '')), ['[email protected]']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', '')), ['[email protected]']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', '')), ['[email protected]']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), ['[email protected]']), 0), 0)))GROUP BY fp_hash) AS evINNER JOIN(SELECT cityHash64(error_tracking_fingerprint_issue_state.fingerprint) AS fp_hash,@@ -1042,7 +1042,7 @@uniqState(nullIf(e.`$session_id`, '')) AS sessions_state,uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_stateFROM events AS e- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null'))), lower('databasenot')), 0), 0), ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null'))), lower('databasenot')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', ''))), lower('databasenot')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', ''))), lower('databasenot')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('databasenot')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('databasenot')), 0), 0)))+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), or(ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null')), ['databasenot']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null')), ['databasenot']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', '')), ['databasenot']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', '')), ['databasenot']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', '')), ['databasenot']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), ['databasenot']), 0), 0)))GROUP BY fp_hash,bin_idx) AS evINNER JOIN@@ -1107,7 +1107,7 @@uniqState(nullIf(e.`$session_id`, '')) AS sessions_state,uniqState(coalesce(nullIf(toString(e.person_id), '00000000-0000-0000-0000-000000000000'), e.distinct_id)) AS users_stateFROM events AS e- WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null'))), lower('databasenotfoundX')), 0), 0), ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null'))), lower('databasenotfoundX')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', ''))), lower('databasenotfoundX')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', ''))), lower('databasenotfoundX')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('databasenotfoundX')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('databasenotfoundX')), 0), 0)), or(ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null'))), lower('clickhouse/client/execute.py')), 0), 0), ifNull(greater(position(lower(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null'))), lower('clickhouse/client/execute.py')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', ''))), lower('clickhouse/client/execute.py')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', ''))), lower('clickhouse/client/execute.py')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('clickhouse/client/execute.py')), 0), 0), ifNull(greater(position(lower(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', ''))), lower('clickhouse/client/execute.py')), 0), 0))))+ WHERE and(equals(e.team_id, 99999), equals(e.event, '$exception'), isNotNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_fingerprint'), ''), 'null'), '^"|"$', '')), ifNull(notILike(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), '%@posthog.com%'), 1), greaterOrEquals(e.timestamp, toDateTime(toDateTime64('2018-01-11 12:11:00.000000', 6, 'UTC'), 'UTC')), lessOrEquals(e.timestamp, toDateTime(toDateTime64('today', 6, 'UTC'), 'UTC')), and(or(ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null')), ['databasenotfoundX']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null')), ['databasenotfoundX']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', '')), ['databasenotfoundX']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', '')), ['databasenotfoundX']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', '')), ['databasenotfoundX']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), ['databasenotfoundX']), 0), 0)), or(ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_types`, ''), 'null')), ['clickhouse/client/execute.py']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(nullIf(nullIf(e.`mat_$exception_values`, ''), 'null')), ['clickhouse/client/execute.py']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_sources'), ''), 'null'), '^"|"$', '')), ['clickhouse/client/execute.py']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$exception_functions'), ''), 'null'), '^"|"$', '')), ['clickhouse/client/execute.py']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, 'email'), ''), 'null'), '^"|"$', '')), ['clickhouse/client/execute.py']), 0), 0), ifNull(greater(multiSearchAnyCaseInsensitive(toString(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.person_properties, 'email'), ''), 'null'), '^"|"$', '')), ['clickhouse/client/execute.py']), 0), 0))))GROUP BY fp_hash,bin_idx) AS evINNER JOINdiff --git a/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.py b/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.pyindex 385e870f027b..5a92e9177fd5 100644--- a/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.py+++ b/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.py@@ -1017,10 +1017,13 @@ class TestMarketingAnalyticsAttributionQueryRunner(ClickhouseTestMixin, BaseTest"products.access_control.backend.property_access_control.get_restricted_properties_with_group_type_index_for_team",side_effect=restrictions_for,):- prepare_and_print_ast(runner.to_query(), context=context, dialect="clickhouse")+ printed = prepare_and_print_ast(runner.to_query(), context=context, dialect="clickhouse")- # The property only reaches ClickHouse as a parameter when the query actually extracts it.- self.assertEqual("plan" in str(context.values), not restricted)+ sql = printed[0] if isinstance(printed, tuple) else printed+ if context.uses_new_events_schema():+ self.assertEqual("properties.plan" in sql or "properties.^plan" in sql, not restricted)+ else:+ self.assertEqual("plan" in str(context.values), not restricted)@parameterized.expand([("zero", 0), ("negative", -1), ("over_the_ceiling", MAX_ATTRIBUTION_WINDOW_DAYS + 1)])def test_lookback_override_outside_the_allowed_range_is_rejected(self, _name: str, days: int):diff --git a/products/posthog_ai/evals/error_tracking/seeders.py b/products/posthog_ai/evals/error_tracking/seeders.pyindex a39f53e4c945..c43d9e4746c2 100644--- a/products/posthog_ai/evals/error_tracking/seeders.py+++ b/products/posthog_ai/evals/error_tracking/seeders.py@@ -35,8 +35,9 @@ from django.apps import appsfrom posthog.clickhouse.client import sync_executefrom posthog.models import Team-from posthog.models.event.sql import INSERT_EVENT_SQL-from posthog.models.event.util import format_clickhouse_timestamp+from posthog.models.event.new_events_schema import use_new_events_schema+from posthog.models.event.sql import EVENTS_JSON_DATA_TABLE, INSERT_EVENT_SQL+from posthog.models.event.util import _json_dumps_for_clickhouse, format_clickhouse_timestampfrom posthog.models.person.sql import INSERT_PERSON_DISTINCT_ID2, INSERT_PERSON_SQLfrom posthog.models.utils import uuid7from posthog.session_recordings.queries.test.session_replay_sql import INSERT_SINGLE_SESSION_REPLAY@@ -223,12 +224,13 @@ def _insert_exception_event(properties: dict[str, Any],) -> None:timestamp_utc = timestamp.astimezone(ZoneInfo("UTC")).strftime("%Y-%m-%d %H:%M:%S.%f")+ native_schema = use_new_events_schema(team.pk)sync_execute(- INSERT_EVENT_SQL(),+ INSERT_EVENT_SQL(table_name=EVENTS_JSON_DATA_TABLE if native_schema else None),{"uuid": str(uuid.uuid4()),"event": "$exception",- "properties": json.dumps(properties),+ "properties": _json_dumps_for_clickhouse(properties) if native_schema else json.dumps(properties),"timestamp": timestamp_utc,"team_id": team.id,"distinct_id": distinct_id,diff --git a/tach.toml b/tach.tomlindex 103ef353e92d..45e8821f19dd 100644--- a/tach.toml+++ b/tach.toml@@ -237,6 +237,7 @@ path = "products.batch_exports"depends_on = ["ee","posthog",+ "products.access_control","products.notifications",]layer = "modules"