: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): codify log_entries read cutover to aux (#106409)
Bryan Ciaraldif9815eb09c00
diff --git a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl b/posthog/clickhouse/hcl/golden/dev/auxiliary.hclindex 99528a038599..fb40ededd054 100644--- a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl@@ -1,4 +1,52 @@database "posthog" {+ table "channel_definition" {+ column "domain" {+ type = "String"+ }+ column "kind" {+ type = "String"+ }+ column "domain_type" {+ type = "Nullable(String)"+ }+ column "type_if_paid" {+ type = "Nullable(String)"+ }+ column "type_if_organic" {+ type = "Nullable(String)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "channel_definition"+ sharding_key = "rand()"+ }+ }++ table "cohortpeople" {+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "sign" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohortpeople"+ sharding_key = "rand()"+ }+ }+table "conversion_goal_attributed_preaggregated" {column "team_id" {type = "Int64"@@ -117,6 +165,193 @@ database "posthog" {}}+ table "events" {+ 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 "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 "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "$group_0" {+ type = "String"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ comment = "column_materializer::$group_4"+ }+ column "$window_id" {+ type = "String"+ comment = "column_materializer::$window_id"+ }+ column "$session_id" {+ type = "String"+ comment = "column_materializer::$session_id"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ column "elements_chain_href" {+ type = "String"+ comment = "column_materializer::elements_chain::href"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::texts"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::ids"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ comment = "column_materializer::elements_chain::elements"+ }+ column "properties_group_custom" {+ type = "Map(String, String)"+ }+ column "properties_group_ai" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "experiment_metric_events_preaggregated" {column "team_id" {type = "Int64"@@ -160,6 +395,93 @@ database "posthog" {}}+ table "groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "Bool"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ sharding_key = "rand()"+ }+ }++ table "heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }+table "hog_invocation_results" {column "team_id" {type = "Int64"@@ -656,6 +978,41 @@ database "posthog" {}}+ table "log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "log_entries_data"+ }+ }+table "log_entries_data" {order_by = ["team_id", "log_source", "log_source_id", "instance_id", "timestamp"]partition_by = "toYYYYMMDD(timestamp)"@@ -1082,6 +1439,111 @@ database "posthog" {}}+ table "person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ sharding_key = "rand()"+ }+ }+table "person_group_membership_config" {order_by = ["team_id"]settings = {@@ -1106,6 +1568,33 @@ database "posthog" {}}+ table "person_static_cohort" {+ column "id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_static_cohort"+ sharding_key = "rand()"+ }+ }+table "platform_alert_events" {column "team_id" {type = "Int64"@@ -1667,6 +2156,281 @@ database "posthog" {}}+ table "raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "sessions"+ remote_database = "posthog"+ remote_table = "raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "first_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ column "snapshot_mode_v2" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "session_replay_features" {column "session_id" {type = "String"diff --git a/posthog/clickhouse/hcl/golden/dev/data.hcl b/posthog/clickhouse/hcl/golden/dev/data.hclindex 5aae220ec1d4..8bd96e76b566 100644--- a/posthog/clickhouse/hcl/golden/dev/data.hcl+++ b/posthog/clickhouse/hcl/golden/dev/data.hcl@@ -2218,10 +2218,9 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "posthog"+ cluster_name = "aux"remote_database = "posthog"- remote_table = "sharded_log_entries"- sharding_key = "rand()"+ remote_table = "log_entries_data"}}@@ -2254,9 +2253,10 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "aux"+ cluster_name = "posthog"remote_database = "posthog"- remote_table = "log_entries_data"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"}}diff --git a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hclindex cb4394a6babb..325b0f0fe8f8 100644--- a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl@@ -1,4 +1,52 @@database "posthog" {+ table "channel_definition" {+ column "domain" {+ type = "String"+ }+ column "kind" {+ type = "String"+ }+ column "domain_type" {+ type = "Nullable(String)"+ }+ column "type_if_paid" {+ type = "Nullable(String)"+ }+ column "type_if_organic" {+ type = "Nullable(String)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "channel_definition"+ sharding_key = "rand()"+ }+ }++ table "cohortpeople" {+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "sign" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohortpeople"+ sharding_key = "rand()"+ }+ }+table "conversion_goal_attributed_preaggregated" {column "team_id" {type = "Int64"@@ -117,6 +165,193 @@ database "posthog" {}}+ table "events" {+ 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 "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 "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "$group_0" {+ type = "String"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ comment = "column_materializer::$group_4"+ }+ column "$window_id" {+ type = "String"+ comment = "column_materializer::$window_id"+ }+ column "$session_id" {+ type = "String"+ comment = "column_materializer::$session_id"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ column "elements_chain_href" {+ type = "String"+ comment = "column_materializer::elements_chain::href"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::texts"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::ids"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ comment = "column_materializer::elements_chain::elements"+ }+ column "properties_group_custom" {+ type = "Map(String, String)"+ }+ column "properties_group_ai" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "experiment_metric_events_preaggregated" {column "team_id" {type = "Int64"@@ -160,6 +395,93 @@ database "posthog" {}}+ table "groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "Bool"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ sharding_key = "rand()"+ }+ }++ table "heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }+table "hog_invocation_results" {column "team_id" {type = "Int64"@@ -700,6 +1022,41 @@ database "posthog" {}}+ table "log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "log_entries_data"+ }+ }+table "log_entries_data" {order_by = ["team_id", "log_source", "log_source_id", "instance_id", "timestamp"]partition_by = "toYYYYMMDD(timestamp)"@@ -1125,6 +1482,111 @@ database "posthog" {}}+ table "person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ sharding_key = "rand()"+ }+ }+table "person_group_membership_config" {order_by = ["team_id"]settings = {@@ -1149,6 +1611,33 @@ database "posthog" {}}+ table "person_static_cohort" {+ column "id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_static_cohort"+ sharding_key = "rand()"+ }+ }+table "platform_alert_events" {column "team_id" {type = "Int64"@@ -1710,6 +2199,281 @@ database "posthog" {}}+ table "raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "first_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ column "snapshot_mode_v2" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "session_replay_features" {column "session_id" {type = "String"diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hclindex be951d1b9dbb..bb7bddda8520 100644--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl@@ -2590,10 +2590,9 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "posthog"+ cluster_name = "aux"remote_database = "posthog"- remote_table = "sharded_log_entries"- sharding_key = "rand()"+ remote_table = "log_entries_data"}}@@ -2626,9 +2625,10 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "aux"+ cluster_name = "posthog"remote_database = "posthog"- remote_table = "log_entries_data"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"}}diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hclindex 2746bbbe73ec..4000492ae96c 100644--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl@@ -4953,10 +4953,9 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "posthog"+ cluster_name = "aux"remote_database = "posthog"- remote_table = "sharded_log_entries"- sharding_key = "rand()"+ remote_table = "log_entries_data"}}@@ -5031,9 +5030,10 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "aux"+ cluster_name = "posthog"remote_database = "posthog"- remote_table = "log_entries_data"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"}}diff --git a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hclindex 2d92cac6dade..c322612a111e 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl@@ -1,4 +1,52 @@database "posthog" {+ table "channel_definition" {+ column "domain" {+ type = "String"+ }+ column "kind" {+ type = "String"+ }+ column "domain_type" {+ type = "Nullable(String)"+ }+ column "type_if_paid" {+ type = "Nullable(String)"+ }+ column "type_if_organic" {+ type = "Nullable(String)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "channel_definition"+ sharding_key = "rand()"+ }+ }++ table "cohortpeople" {+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "sign" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohortpeople"+ sharding_key = "rand()"+ }+ }+table "conversion_goal_attributed_preaggregated" {column "team_id" {type = "Int64"@@ -117,6 +165,193 @@ database "posthog" {}}+ table "events" {+ 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 "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 "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "$group_0" {+ type = "String"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ comment = "column_materializer::$group_4"+ }+ column "$window_id" {+ type = "String"+ comment = "column_materializer::$window_id"+ }+ column "$session_id" {+ type = "String"+ comment = "column_materializer::$session_id"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ column "elements_chain_href" {+ type = "String"+ comment = "column_materializer::elements_chain::href"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::texts"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::ids"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ comment = "column_materializer::elements_chain::elements"+ }+ column "properties_group_custom" {+ type = "Map(String, String)"+ }+ column "properties_group_ai" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "experiment_metric_events_preaggregated" {column "team_id" {type = "Int64"@@ -160,6 +395,93 @@ database "posthog" {}}+ table "groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "Bool"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ sharding_key = "rand()"+ }+ }++ table "heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }+table "hog_invocation_results" {column "team_id" {type = "Int64"@@ -656,6 +978,41 @@ database "posthog" {}}+ table "log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "log_entries_data"+ }+ }+table "log_entries_data" {order_by = ["team_id", "log_source", "log_source_id", "instance_id", "timestamp"]partition_by = "toYYYYMMDD(timestamp)"@@ -1082,6 +1439,111 @@ database "posthog" {}}+ table "person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ sharding_key = "rand()"+ }+ }+table "person_group_membership_config" {order_by = ["team_id"]settings = {@@ -1106,6 +1568,33 @@ database "posthog" {}}+ table "person_static_cohort" {+ column "id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_static_cohort"+ sharding_key = "rand()"+ }+ }+table "platform_alert_events" {column "team_id" {type = "Int64"@@ -1667,6 +2156,281 @@ database "posthog" {}}+ table "raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "sessions"+ remote_database = "posthog"+ remote_table = "raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "first_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ column "snapshot_mode_v2" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "session_replay_features" {column "session_id" {type = "String"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl b/posthog/clickhouse/hcl/golden/prod-eu/data.hclindex 69067173a70d..8e2db8bb1e1a 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/data.hcl@@ -2276,10 +2276,9 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "posthog"+ cluster_name = "aux"remote_database = "posthog"- remote_table = "sharded_log_entries"- sharding_key = "rand()"+ remote_table = "log_entries_data"}}@@ -2312,9 +2311,10 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "aux"+ cluster_name = "posthog"remote_database = "posthog"- remote_table = "log_entries_data"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"}}diff --git a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hclindex 05f7d1eba7d4..ea771fe74cb3 100644--- a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl@@ -1,4 +1,52 @@database "posthog" {+ table "channel_definition" {+ column "domain" {+ type = "String"+ }+ column "kind" {+ type = "String"+ }+ column "domain_type" {+ type = "Nullable(String)"+ }+ column "type_if_paid" {+ type = "Nullable(String)"+ }+ column "type_if_organic" {+ type = "Nullable(String)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "channel_definition"+ sharding_key = "rand()"+ }+ }++ table "cohortpeople" {+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "sign" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohortpeople"+ sharding_key = "rand()"+ }+ }+table "conversion_goal_attributed_preaggregated" {column "team_id" {type = "Int64"@@ -117,6 +165,193 @@ database "posthog" {}}+ table "events" {+ 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 "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 "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "$group_0" {+ type = "String"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ comment = "column_materializer::$group_4"+ }+ column "$window_id" {+ type = "String"+ comment = "column_materializer::$window_id"+ }+ column "$session_id" {+ type = "String"+ comment = "column_materializer::$session_id"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ column "elements_chain_href" {+ type = "String"+ comment = "column_materializer::elements_chain::href"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::texts"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::ids"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ comment = "column_materializer::elements_chain::elements"+ }+ column "properties_group_custom" {+ type = "Map(String, String)"+ }+ column "properties_group_ai" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "experiment_metric_events_preaggregated" {column "team_id" {type = "Int64"@@ -160,6 +395,93 @@ database "posthog" {}}+ table "groups" {+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "Bool"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ sharding_key = "rand()"+ }+ }++ table "heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }+table "hog_invocation_results" {column "team_id" {type = "Int64"@@ -694,6 +1016,41 @@ database "posthog" {}}+ table "log_entries" {+ column "team_id" {+ type = "UInt64"+ }+ column "log_source" {+ type = "LowCardinality(String)"+ }+ column "log_source_id" {+ type = "String"+ }+ column "instance_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "level" {+ type = "LowCardinality(String)"+ }+ column "message" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "log_entries_data"+ }+ }+table "log_entries_data" {order_by = ["team_id", "log_source", "log_source_id", "instance_id", "timestamp"]partition_by = "toYYYYMMDD(timestamp)"@@ -1120,6 +1477,111 @@ database "posthog" {}}+ table "person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ sharding_key = "rand()"+ }+ }+table "person_group_membership_config" {order_by = ["team_id"]settings = {@@ -1144,6 +1606,33 @@ database "posthog" {}}+ table "person_static_cohort" {+ column "id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_static_cohort"+ sharding_key = "rand()"+ }+ }+table "platform_alert_events" {column "team_id" {type = "Int64"@@ -1705,6 +2194,281 @@ database "posthog" {}}+ table "raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "sessions"+ remote_database = "posthog"+ remote_table = "raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }++ table "session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "first_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ column "snapshot_mode_v2" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+table "session_replay_features" {column "session_id" {type = "String"diff --git a/posthog/clickhouse/hcl/golden/prod-us/data.hcl b/posthog/clickhouse/hcl/golden/prod-us/data.hclindex 2a9d839a0823..fa0d10af2ba7 100644--- a/posthog/clickhouse/hcl/golden/prod-us/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/data.hcl@@ -2251,10 +2251,9 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "posthog"+ cluster_name = "aux"remote_database = "posthog"- remote_table = "sharded_log_entries"- sharding_key = "rand()"+ remote_table = "log_entries_data"}}@@ -2287,9 +2286,10 @@ database "posthog" {type = "UInt64"}engine "distributed" {- cluster_name = "aux"+ cluster_name = "posthog"remote_database = "posthog"- remote_table = "log_entries_data"+ remote_table = "sharded_log_entries"+ sharding_key = "rand()"}}diff --git a/posthog/clickhouse/hcl/manifest.hcl b/posthog/clickhouse/hcl/manifest.hclindex 7ffd9994ab1e..34e5a1a1a1c6 100644--- a/posthog/clickhouse/hcl/manifest.hcl+++ b/posthog/clickhouse/hcl/manifest.hcl@@ -61,10 +61,10 @@ role "apm" {# same WarpStream pipeline as the prod envs; roles/ai_events/dev downsizes the# Kafka consumer for dev volume.role "ai_events" {- env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local"] }- env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod", "roles/ai_events/dev"] }- env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }- env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/ai_events/shared", "roles/ai_events/local"] }+ env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/ai_events/shared", "roles/ai_events/prod", "roles/ai_events/dev"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/ai_events/shared", "roles/ai_events/prod"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/ai_events/shared", "roles/ai_events/prod"] }}# AUX satellite: auxiliary tables (error tracking, hog invocations, message assets,@@ -74,10 +74,10 @@ role "ai_events" {# hosts the ingestion_warnings store; prod-us adds the Distributed proxy onto the data# cluster. prod goldens are dump-baselined (not live-verifiable here).role "aux" {- env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local"] }- env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/dev"] }- env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-eu"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/log_entries_aux_alias", "roles/coshared/main_join_readers", "roles/coshared/person_shims", "roles/coshared/main_proxies", "roles/coshared/log_entries_aux_join_readers", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local"] }+ env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/log_entries_aux_alias", "roles/coshared/main_join_readers", "roles/coshared/person_shims", "roles/coshared/main_proxies", "roles/coshared/log_entries_aux_join_readers", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/dev"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/log_entries_aux_alias", "roles/coshared/main_join_readers", "roles/coshared/person_shims", "roles/coshared/main_proxies", "roles/coshared/log_entries_aux_join_readers", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/log_entries_aux_alias", "roles/coshared/main_join_readers", "roles/coshared/person_shims", "roles/coshared/main_proxies", "roles/coshared/log_entries_aux_join_readers", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-eu"] }}# SESSIONS satellite: the local node runs only the shared query_log_archive path@@ -95,9 +95,9 @@ role "aux" {# shape below is what migrations produce.role "sessions" {env "local-multi" { layers = ["roles/shared"] }- env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/sessions_data", "roles/sessions/shared"] }- env "prod-us" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/coshared/events_recent_write", "roles/sessions/shared", "roles/sessions/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/sessions/shared", "roles/sessions/prod-eu"] }+ env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/sessions/shared"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/coshared/events_recent_write", "roles/sessions/shared", "roles/sessions/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/sessions/shared", "roles/sessions/prod-eu"] }}# BATCH_EXPORTS satellite: hosts the sharded_events_recent data table (the recent-events@@ -118,10 +118,10 @@ role "batch_exports" {# columns per env that are added out-of-band and churn constantly, so their goldens# live in PostHog/posthog-cloud-infra (clickhouse/hcl/), not the OSS gate.role "data" {- env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/data/cloud", "roles/coshared/log_entries_write", "roles/data/dev"] }- env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/data/cloud", "roles/data/prod", "roles/data/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/data/cloud", "roles/coshared/log_entries_write", "roles/data/prod", "roles/data/prod-eu"] }- env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/ai_events_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/data/local"] }+ env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/coshared/main_proxies", "roles/data/cloud", "roles/coshared/log_entries_write", "roles/data/dev"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/coshared/main_proxies", "roles/data/cloud", "roles/data/prod", "roles/data/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/coshared/main_proxies", "roles/data/cloud", "roles/coshared/log_entries_write", "roles/data/prod", "roles/data/prod-eu"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/data/shared", "roles/data/common", "roles/coshared/main_proxies", "roles/data/local"] }}# INGESTION satellites: the Kafka consumer layer. Each node carries the kafka_* engine@@ -146,7 +146,7 @@ role "medium" {# and not MULTINODE_CLICKHOUSE. Composed as the deduped union of the local-multi stacks it# hosts, so any name two of those roles declare fails this load instead of drifting.role "all" {- env "local-single" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/apm_ingest", "roles/coshared/logs_avro_ingest", "roles/coshared/custom_metrics", "roles/ops/shared", "roles/ops/local", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/local", "roles/apm/shared", "roles/apm/local", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local", "roles/coshared/sessions_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/log_entries_aux_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/ingestion_small/shared", "roles/data/shared", "roles/data/common", "roles/data/local", "roles/ingestion_events/local", "roles/ingestion_events/local-single", "roles/ingestion_small/local", "roles/ingestion_medium/local"] }+ env "local-single" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/apm_ingest", "roles/coshared/logs_avro_ingest", "roles/coshared/custom_metrics", "roles/ops/shared", "roles/ops/local", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/local", "roles/apm/shared", "roles/apm/local", "roles/coshared/ai_events_data", "roles/coshared/person_shims", "roles/ai_events/shared", "roles/ai_events/local", "roles/coshared/aux_data", "roles/coshared/log_entries_aux", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local", "roles/coshared/sessions_data", "roles/coshared/main_join_readers", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/log_entries_aux_write", "roles/coshared/session_replay_write", "roles/coshared/person_group_membership_config", "roles/ingestion_small/shared", "roles/data/shared", "roles/data/common", "roles/coshared/main_proxies", "roles/data/local", "roles/ingestion_events/local", "roles/ingestion_events/local-single", "roles/ingestion_small/local", "roles/ingestion_medium/local"] }}# role "endpoints" {diff --git a/posthog/clickhouse/hcl/roles/auxiliary/prod/patches.hcl b/posthog/clickhouse/hcl/roles/auxiliary/prod/patches.hclindex 88540aa64368..33b5c67847fa 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/prod/patches.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/prod/patches.hcl@@ -11,4 +11,13 @@ database "posthog" {storage_policy = "s3_tiered"}}+ # Cloud stores raw_sessions on the sessions satellite, not behind the data cluster.+ patch_table "raw_sessions" {+ engine "distributed" {+ cluster_name = "sessions"+ remote_database = "posthog"+ remote_table = "raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }}diff --git a/posthog/clickhouse/hcl/roles/coshared/ai_events_data/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/ai_events_data/tables.hclindex 744251b298dc..1388e4bca412 100644--- a/posthog/clickhouse/hcl/roles/coshared/ai_events_data/tables.hcl+++ b/posthog/clickhouse/hcl/roles/coshared/ai_events_data/tables.hcl@@ -3,60 +3,6 @@# (kafka meta columns, minmax indexes, ReplacingMergeTree engines) are patch_table# blocks in roles/data/local.database "posthog" {- table "person" {- column "id" {- type = "UUID"- }- column "created_at" {- type = "DateTime64(3)"- }- column "team_id" {- type = "Int64"- }- column "properties" {- type = "String"- }- column "is_identified" {- type = "Int8"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "UInt64"- }- column "last_seen_at" {- type = "Nullable(DateTime64(3))"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "person"- }- }-- table "person_distinct_id2" {- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "Int64"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "person_distinct_id2"- }- }table "_ai_events_columns" {abstract = truediff --git a/posthog/clickhouse/hcl/roles/coshared/log_entries_aux/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/log_entries_aux/tables.hclindex 47a570b60089..f4752f96ab3b 100644--- a/posthog/clickhouse/hcl/roles/coshared/log_entries_aux/tables.hcl+++ b/posthog/clickhouse/hcl/roles/coshared/log_entries_aux/tables.hcl@@ -1,5 +1,5 @@-# log_entries on the aux cluster: the column core and-# the Distributed reader, composed by the aux and data nodes. The data table lives in+# log_entries on the aux cluster: the column core and the app-facing `log_entries`+# Distributed reader, composed by the aux and data nodes. The data table lives in# roles/auxiliary/shared, the Kafka consumer trio in roles/coshared/log_entries_aux_write.database "posthog" {table "_log_entries_aux_columns" {@@ -14,7 +14,7 @@ database "posthog" {column "_timestamp" { type = "DateTime" }column "_offset" { type = "UInt64" }}- table "log_entries_distributed" {+ table "log_entries" {extend = "_log_entries_aux_columns"engine "distributed" {cluster_name = "aux"diff --git a/posthog/clickhouse/hcl/roles/coshared/log_entries_aux_alias/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/log_entries_aux_alias/tables.hclnew file mode 100644index 000000000000..0431d510457b--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/log_entries_aux_alias/tables.hcl@@ -0,0 +1,13 @@+# A second name for the aux log_entries reader on the aux nodes, so queries that name+# log_entries_distributed resolve there. Not composed on local-single, because the+# combined node carries the data-role log_entries_distributed (the main-cluster reader).+database "posthog" {+ table "log_entries_distributed" {+ extend = "_log_entries_aux_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "log_entries_data"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/log_entries_aux_join_readers/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/log_entries_aux_join_readers/tables.hclnew file mode 100644index 000000000000..438d1b015fff--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/log_entries_aux_join_readers/tables.hcl@@ -0,0 +1,298 @@+# Aux-only deltas for the Distributed readers the aux nodes carry for tables that log_entries+# queries join. log_entries reads aux, so ClickHouse runs such a JOIN on the aux nodes and the+# right-hand table must resolve there. Created by migration 0352+# (posthog/clickhouse/log_entries_aux_readers.py). The readers shared with other roles come from+# roles/coshared/{main_join_readers,person_shims,main_proxies}; roles/auxiliary/prod points+# raw_sessions at the sessions satellite. The cloud data clusters' mat_ columns are not declared+# (posthog-cloud-infra owns them).+database "posthog" {+ table "channel_definition" {+ column "domain" {+ type = "String"+ }+ column "kind" {+ type = "String"+ }+ column "domain_type" {+ type = "Nullable(String)"+ }+ column "type_if_paid" {+ type = "Nullable(String)"+ }+ column "type_if_organic" {+ type = "Nullable(String)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "channel_definition"+ sharding_key = "rand()"+ }+ }++ table "events" {+ 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 "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 "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "dmat_string_0" {+ type = "Nullable(String)"+ }+ column "dmat_string_1" {+ type = "Nullable(String)"+ }+ column "dmat_string_2" {+ type = "Nullable(String)"+ }+ column "dmat_string_3" {+ type = "Nullable(String)"+ }+ column "dmat_string_4" {+ type = "Nullable(String)"+ }+ column "dmat_string_5" {+ type = "Nullable(String)"+ }+ column "dmat_string_6" {+ type = "Nullable(String)"+ }+ column "dmat_string_7" {+ type = "Nullable(String)"+ }+ column "dmat_string_8" {+ type = "Nullable(String)"+ }+ column "dmat_string_9" {+ type = "Nullable(String)"+ }+ column "$group_0" {+ type = "String"+ comment = "column_materializer::$group_0"+ }+ column "$group_1" {+ type = "String"+ comment = "column_materializer::$group_1"+ }+ column "$group_2" {+ type = "String"+ comment = "column_materializer::$group_2"+ }+ column "$group_3" {+ type = "String"+ comment = "column_materializer::$group_3"+ }+ column "$group_4" {+ type = "String"+ comment = "column_materializer::$group_4"+ }+ column "$window_id" {+ type = "String"+ comment = "column_materializer::$window_id"+ }+ column "$session_id" {+ type = "String"+ comment = "column_materializer::$session_id"+ }+ column "$session_id_uuid" {+ type = "Nullable(UInt128)"+ }+ column "elements_chain_href" {+ type = "String"+ comment = "column_materializer::elements_chain::href"+ }+ column "elements_chain_texts" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::texts"+ }+ column "elements_chain_ids" {+ type = "Array(String)"+ comment = "column_materializer::elements_chain::ids"+ }+ column "elements_chain_elements" {+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"+ comment = "column_materializer::elements_chain::elements"+ }+ column "properties_group_custom" {+ type = "Map(String, String)"+ }+ column "properties_group_ai" {+ type = "Map(String, String)"+ }+ column "properties_group_feature_flags" {+ type = "Map(String, String)"+ }+ column "person_properties_map_custom" {+ type = "Map(String, String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ default = "now64()"+ }+ column "consumer_breadcrumbs" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ # The data node stores groups; here the name is a Distributed reader onto it.+ table "groups" {+ override = true+ column "group_type_index" {+ type = "UInt8"+ }+ column "group_key" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "group_properties" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "Bool"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "groups"+ sharding_key = "rand()"+ }+ }++ # Aux reads the person tables through one replica with the Kafka meta columns, like the+ # readers the cloud regions run. The base shims live in roles/coshared/person_shims.+ patch_table "person" {+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person"+ sharding_key = "rand()"+ }+ }++ patch_table "person_distinct_id2" {+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ sharding_key = "rand()"+ }+ }++ patch_table "person_distinct_id_overrides" {+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ sharding_key = "rand()"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/main_join_readers/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/main_join_readers/tables.hclnew file mode 100644index 000000000000..528b11050c4a--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/main_join_readers/tables.hcl@@ -0,0 +1,262 @@+# Distributed readers back to the main cluster for the person, cohort and raw_sessions+# tables, so JOINs resolve on the satellites that run them (sessions, aux). The data node+# composes them too; roles/data/{local,cloud} turn them into the storage tables there.+database "posthog" {+ table "cohortpeople" {+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "sign" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohortpeople"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "person_static_cohort" {+ column "id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_static_cohort"+ sharding_key = "rand()"+ }+ }++ table "raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/main_proxies/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/main_proxies/tables.hclnew file mode 100644index 000000000000..e0e6ac2845a1--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/main_proxies/tables.hcl@@ -0,0 +1,158 @@+# Distributed proxies onto the main cluster's sharded tables, carried by the data node+# and by the aux nodes so JOINs against log_entries resolve there.+database "posthog" {+ table "heatmaps" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "x" {+ type = "Int16"+ }+ column "y" {+ type = "Int16"+ }+ column "scale_factor" {+ type = "Int16"+ }+ column "viewport_width" {+ type = "Int16"+ }+ column "viewport_height" {+ type = "Int16"+ }+ column "pointer_target_fixed" {+ type = "Bool"+ }+ column "current_url" {+ type = "String"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_heatmaps"+ sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"+ }+ }++ table "session_replay_events" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "first_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"+ }+ column "snapshot_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"+ }+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"+ }+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"+ }+ column "snapshot_mode_v2" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/person_shims/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/person_shims/tables.hclnew file mode 100644index 000000000000..61f9f681cf39--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/person_shims/tables.hcl@@ -0,0 +1,60 @@+# The person / person_distinct_id2 Distributed shims (migration 0240), hosted by the+# ai_events and aux satellites and the data node. The data node's storage forms are+# patch_table blocks in roles/data/local; aux's reader delta is in+# roles/coshared/log_entries_aux_join_readers.+database "posthog" {+ table "person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "person"+ }+ }++ table "person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/sessions_data/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/sessions_data/tables.hclindex 3f38f471f2e3..912ca2f0938e 100644--- a/posthog/clickhouse/hcl/roles/coshared/sessions_data/tables.hcl+++ b/posthog/clickhouse/hcl/roles/coshared/sessions_data/tables.hcl@@ -4,89 +4,6 @@# of sessions/raw_sessions are override declarations in roles/sessions/shared# (they carry sample_by, which patches cannot express).database "posthog" {- table "cohortpeople" {- column "person_id" {- type = "UUID"- }- column "cohort_id" {- type = "Int64"- }- column "team_id" {- type = "Int64"- }- column "sign" {- type = "Int8"- }- column "version" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "cohortpeople"- sharding_key = "rand()"- }- }-- table "person_distinct_id_overrides" {- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "person_distinct_id_overrides"- sharding_key = "sipHash64(distinct_id)"- }- }-- table "person_static_cohort" {- column "id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "cohort_id" {- type = "Int64"- }- column "team_id" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "person_static_cohort"- sharding_key = "rand()"- }- }table "web_pre_aggregated_teams" {column "team_id" {@@ -261,177 +178,4 @@ database "posthog" {}}- table "raw_sessions" {- column "team_id" {- type = "Int64"- }- column "session_id_v7" {- type = "UInt128"- }- column "distinct_id" {- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"- }- column "min_timestamp" {- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "max_inserted_at" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "entry_url" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "end_url" {- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"- }- column "last_external_click_url" {- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"- }- column "initial_browser" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_browser_version" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_os" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_os_version" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_device_type" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_viewport_width" {- type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"- }- column "initial_viewport_height" {- type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"- }- column "initial_geoip_country_code" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_geoip_subdivision_1_code" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_geoip_subdivision_1_name" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_geoip_subdivision_city_name" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_geoip_time_zone" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_referring_domain" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_utm_source" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_utm_campaign" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_utm_medium" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_utm_term" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_utm_content" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_gclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_gad_source" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_gclsrc" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_dclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_gbraid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_wbraid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_fbclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_msclkid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_twclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_li_fat_id" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_mc_cid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_igshid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_ttclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_epik" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_qclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_sccid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial__kx" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_irclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "pageview_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "pageview_uniq" {- type = "AggregateFunction(uniq, Nullable(UUID))"- }- column "autocapture_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "autocapture_uniq" {- type = "AggregateFunction(uniq, Nullable(UUID))"- }- column "screen_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "screen_uniq" {- type = "AggregateFunction(uniq, Nullable(UUID))"- }- column "maybe_has_session_replay" {- type = "SimpleAggregateFunction(max, Bool)"- }- column "page_screen_autocapture_uniq_up_to" {- type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"- }- column "vitals_lcp" {- type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_raw_sessions"- sharding_key = "cityHash64(session_id_v7)"- }- }}diff --git a/posthog/clickhouse/hcl/roles/data/common/cloud_and_local.hcl b/posthog/clickhouse/hcl/roles/data/common/cloud_and_local.hclindex dc641e2aee83..e048a7198ae3 100644--- a/posthog/clickhouse/hcl/roles/data/common/cloud_and_local.hcl+++ b/posthog/clickhouse/hcl/roles/data/common/cloud_and_local.hcl@@ -471,60 +471,6 @@ SQL}}- table "heatmaps" {- column "session_id" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "x" {- type = "Int16"- }- column "y" {- type = "Int16"- }- column "scale_factor" {- type = "Int16"- }- column "viewport_width" {- type = "Int16"- }- column "viewport_height" {- type = "Int16"- }- column "pointer_target_fixed" {- type = "Bool"- }- column "current_url" {- type = "String"- }- column "type" {- type = "LowCardinality(String)"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_heatmaps"- sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"- }- }-table "llma_metrics_daily" {order_by = ["team_id", "date", "metric_name"]partition_by = "toYYYYMM(date)"@@ -549,7 +495,9 @@ SQL}}- table "log_entries" {+ # Main-cluster reader over sharded_log_entries, kept as the rollback target for log_entries+ # reads. The app-facing `log_entries` aux reader comes from roles/coshared/log_entries_aux.+ table "log_entries_distributed" {column "team_id" {type = "UInt64"}diff --git a/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hcl b/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hclindex df8fe4134109..29297717ed2c 100644--- a/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hcl+++ b/posthog/clickhouse/hcl/roles/data/common/shared_declarations.hcl@@ -1079,107 +1079,6 @@ SQL}- table "session_replay_events" {- column "session_id" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "min_first_timestamp" {- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"- }- column "max_last_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "first_url" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "keypress_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_activity_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "active_milliseconds" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_log_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_warn_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_error_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "size" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "message_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "snapshot_source" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "snapshot_library" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }- column "is_deleted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"- }- column "ai_tags_fixed" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "ai_tags_freeform" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "ai_highlighted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"- }- column "surfacing_score" {- type = "SimpleAggregateFunction(max, Nullable(Float32))"- }- column "snapshot_mode_v2" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_session_replay_events"- sharding_key = "sipHash64(distinct_id)"- }- }-view "sessions_v" {query = <<SQLSELECTdiff --git a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql b/posthog/clickhouse/hcl/sql/dev/auxiliary.sqlindex 0960505d88d0..29ca23d4b3f8 100644--- a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/dev/auxiliary.sql@@ -1,6 +1,102 @@-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.-- Full CREATE schema for the dev/aux node. Apply to a fresh ClickHouse to build it.+CREATE TABLE posthog.channel_definition (+ domain String,+ kind String,+ domain_type Nullable(String),+ type_if_paid Nullable(String),+ type_if_organic Nullable(String)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'channel_definition', rand());+CREATE TABLE posthog.cohortpeople (+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ sign Int8,+ version UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohortpeople', rand());+CREATE TABLE posthog.events (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ 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 CODEC(ZSTD(3)),+ 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)),+ 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,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String),+ $group_0 String COMMENT 'column_materializer::$group_0',+ $group_1 String COMMENT 'column_materializer::$group_1',+ $group_2 String COMMENT 'column_materializer::$group_2',+ $group_3 String COMMENT 'column_materializer::$group_3',+ $group_4 String COMMENT 'column_materializer::$group_4',+ $window_id String COMMENT 'column_materializer::$window_id',+ $session_id String COMMENT 'column_materializer::$session_id',+ $session_id_uuid Nullable(UInt128),+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',+ properties_group_custom Map(String, String),+ properties_group_ai Map(String, String),+ properties_group_feature_flags Map(String, String),+ person_properties_map_custom Map(String, String),+ _timestamp DateTime,+ _offset UInt64,+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ consumer_breadcrumbs Array(String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));+CREATE TABLE posthog.groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String,+ _timestamp DateTime,+ _offset UInt64,+ is_deleted Bool+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'groups', rand());+CREATE TABLE posthog.heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));CREATE TABLE posthog.hog_invocation_results_data (team_id Int64,function_kind LowCardinality(String),@@ -167,12 +263,52 @@ CREATE TABLE posthog.message_assets_data (INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3)),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person', rand());+CREATE TABLE posthog.person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id2', rand());+CREATE TABLE posthog.person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides', rand());CREATE TABLE posthog.person_group_membership_config (team_id Int64,group_type_index UInt8,enabled UInt8,version UInt64) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_group_membership_config', '{replica}-{shard}', version) ORDER BY (team_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.person_static_cohort (+ id UUID,+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_static_cohort', rand());CREATE TABLE posthog.property_values (team_id Int64 CODEC(DoubleDelta, ZSTD(1)),property_type LowCardinality(String),@@ -306,6 +442,95 @@ CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (_partition UInt64,INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;+CREATE TABLE posthog.raw_sessions (+ team_id Int64,+ session_id_v7 UInt128,+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ pageview_count SimpleAggregateFunction(sum, Int64),+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),+ autocapture_count SimpleAggregateFunction(sum, Int64),+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),+ screen_count SimpleAggregateFunction(sum, Int64),+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))+) ENGINE = Distributed('sessions', 'posthog', 'raw_sessions', cityHash64(session_id_v7));+CREATE TABLE posthog.session_replay_events (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),+ snapshot_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),+ snapshot_mode_v2 AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.sharded_billing_usage_records (schema_version UInt8,record_id String,@@ -1253,6 +1478,17 @@ CREATE TABLE posthog.hog_invocation_results (_offset UInt64,_partition UInt64) ENGINE = Distributed('aux', 'posthog', 'hog_invocation_results_data');+CREATE TABLE posthog.log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('aux', 'posthog', 'log_entries_data');CREATE TABLE posthog.marketing_conversions_preaggregated (team_id Int64,job_id UUID,diff --git a/posthog/clickhouse/hcl/sql/dev/data.sql b/posthog/clickhouse/hcl/sql/dev/data.sqlindex fee75254b0d9..d7d58f7d518f 100644--- a/posthog/clickhouse/hcl/sql/dev/data.sql+++ b/posthog/clickhouse/hcl/sql/dev/data.sql@@ -450,7 +450,7 @@ CREATE TABLE posthog.llma_metrics_daily (metric_name String,metric_value Float64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.llma_metrics_daily', '{replica}-{shard}') ORDER BY (team_id, date, metric_name) PARTITION BY toYYYYMM(date) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.log_entries_distributed (+CREATE TABLE posthog.log_entries (team_id UInt64,log_source LowCardinality(String),log_source_id String,@@ -2619,7 +2619,7 @@ CREATE TABLE posthog.heatmaps (_offset UInt64,_partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));-CREATE TABLE posthog.log_entries (+CREATE TABLE posthog.log_entries_distributed (team_id UInt64,log_source LowCardinality(String),log_source_id String,diff --git a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sqlindex b7e91d4434d5..30e632e2befb 100644--- a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql@@ -1,6 +1,102 @@-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.-- Full CREATE schema for the local-multi/aux node. Apply to a fresh ClickHouse to build it.+CREATE TABLE posthog.channel_definition (+ domain String,+ kind String,+ domain_type Nullable(String),+ type_if_paid Nullable(String),+ type_if_organic Nullable(String)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'channel_definition', rand());+CREATE TABLE posthog.cohortpeople (+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ sign Int8,+ version UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohortpeople', rand());+CREATE TABLE posthog.events (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ 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 CODEC(ZSTD(3)),+ 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)),+ 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,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String),+ $group_0 String COMMENT 'column_materializer::$group_0',+ $group_1 String COMMENT 'column_materializer::$group_1',+ $group_2 String COMMENT 'column_materializer::$group_2',+ $group_3 String COMMENT 'column_materializer::$group_3',+ $group_4 String COMMENT 'column_materializer::$group_4',+ $window_id String COMMENT 'column_materializer::$window_id',+ $session_id String COMMENT 'column_materializer::$session_id',+ $session_id_uuid Nullable(UInt128),+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',+ properties_group_custom Map(String, String),+ properties_group_ai Map(String, String),+ properties_group_feature_flags Map(String, String),+ person_properties_map_custom Map(String, String),+ _timestamp DateTime,+ _offset UInt64,+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ consumer_breadcrumbs Array(String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));+CREATE TABLE posthog.groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String,+ _timestamp DateTime,+ _offset UInt64,+ is_deleted Bool+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'groups', rand());+CREATE TABLE posthog.heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));CREATE TABLE posthog.hog_invocation_results_data (team_id Int64,function_kind LowCardinality(String),@@ -181,12 +277,52 @@ CREATE TABLE posthog.message_assets_data (INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3)),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person', rand());+CREATE TABLE posthog.person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id2', rand());+CREATE TABLE posthog.person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides', rand());CREATE TABLE posthog.person_group_membership_config (team_id Int64,group_type_index UInt8,enabled UInt8,version UInt64) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_group_membership_config', '{replica}-{shard}', version) ORDER BY (team_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.person_static_cohort (+ id UUID,+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_static_cohort', rand());CREATE TABLE posthog.property_values (team_id Int64 CODEC(DoubleDelta, ZSTD(1)),property_type LowCardinality(String),@@ -320,6 +456,95 @@ CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (_partition UInt64,INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;+CREATE TABLE posthog.raw_sessions (+ team_id Int64,+ session_id_v7 UInt128,+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ pageview_count SimpleAggregateFunction(sum, Int64),+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),+ autocapture_count SimpleAggregateFunction(sum, Int64),+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),+ screen_count SimpleAggregateFunction(sum, Int64),+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_raw_sessions', cityHash64(session_id_v7));+CREATE TABLE posthog.session_replay_events (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),+ snapshot_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),+ snapshot_mode_v2 AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.sharded_billing_usage_records (schema_version UInt8,record_id String,@@ -1274,6 +1499,17 @@ CREATE TABLE posthog.hog_invocation_results (_offset UInt64,_partition UInt64) ENGINE = Distributed('aux', 'posthog', 'hog_invocation_results_data');+CREATE TABLE posthog.log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('aux', 'posthog', 'log_entries_data');CREATE TABLE posthog.marketing_conversions_preaggregated (team_id Int64,job_id UUID,diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sqlindex 52900357fe49..1e84f760afc1 100644--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql@@ -459,7 +459,7 @@ CREATE TABLE posthog.llma_metrics_daily (metric_name String,metric_value Float64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.llma_metrics_daily', '{replica}-{shard}') ORDER BY (team_id, date, metric_name) PARTITION BY toYYYYMM(date) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.log_entries_distributed (+CREATE TABLE posthog.log_entries (team_id UInt64,log_source LowCardinality(String),log_source_id String,@@ -3219,7 +3219,7 @@ CREATE TABLE posthog.ingestion_warnings (_offset UInt64,_partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_ingestion_warnings', rand());-CREATE TABLE posthog.log_entries (+CREATE TABLE posthog.log_entries_distributed (team_id UInt64,log_source LowCardinality(String),log_source_id String,diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sqlindex 3c3127c09d64..1faad78fe53c 100644--- a/posthog/clickhouse/hcl/sql/local-single/all.sql+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql@@ -989,17 +989,6 @@ CREATE TABLE posthog.log_entries_data (_timestamp DateTime,_offset UInt64) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.log_entries_data', '{replica}', _timestamp) ORDER BY (team_id, log_source, log_source_id, instance_id, timestamp) PARTITION BY toYYYYMMDD(timestamp) TTL toDate(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;-CREATE TABLE posthog.log_entries_distributed (- team_id UInt64,- log_source LowCardinality(String),- log_source_id String,- instance_id String,- timestamp DateTime64(6, 'UTC'),- level LowCardinality(String),- message String,- _timestamp DateTime,- _offset UInt64-) ENGINE = Distributed('aux', 'posthog', 'log_entries_data');CREATE TABLE posthog.logs32 (time_bucket DateTime MATERIALIZED toStartOfDay(timestamp) CODEC(DoubleDelta, ZSTD(1)),original_expiry_timestamp DateTime64(6) CODEC(DoubleDelta, ZSTD(1)),@@ -6730,6 +6719,17 @@ CREATE TABLE posthog.log_entries (message String,_timestamp DateTime,_offset UInt64+) ENGINE = Distributed('aux', 'posthog', 'log_entries_data');+CREATE TABLE posthog.log_entries_distributed (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_log_entries', rand());CREATE TABLE posthog.logs (time_bucket DateTime MATERIALIZED toStartOfDay(timestamp) CODEC(DoubleDelta, ZSTD(1)),diff --git a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sqlindex 4106eda6fcde..3ffab4c21aa6 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql@@ -1,6 +1,102 @@-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.-- Full CREATE schema for the prod-eu/aux node. Apply to a fresh ClickHouse to build it.+CREATE TABLE posthog.channel_definition (+ domain String,+ kind String,+ domain_type Nullable(String),+ type_if_paid Nullable(String),+ type_if_organic Nullable(String)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'channel_definition', rand());+CREATE TABLE posthog.cohortpeople (+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ sign Int8,+ version UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohortpeople', rand());+CREATE TABLE posthog.events (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ 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 CODEC(ZSTD(3)),+ 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)),+ 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,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String),+ $group_0 String COMMENT 'column_materializer::$group_0',+ $group_1 String COMMENT 'column_materializer::$group_1',+ $group_2 String COMMENT 'column_materializer::$group_2',+ $group_3 String COMMENT 'column_materializer::$group_3',+ $group_4 String COMMENT 'column_materializer::$group_4',+ $window_id String COMMENT 'column_materializer::$window_id',+ $session_id String COMMENT 'column_materializer::$session_id',+ $session_id_uuid Nullable(UInt128),+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',+ properties_group_custom Map(String, String),+ properties_group_ai Map(String, String),+ properties_group_feature_flags Map(String, String),+ person_properties_map_custom Map(String, String),+ _timestamp DateTime,+ _offset UInt64,+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ consumer_breadcrumbs Array(String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));+CREATE TABLE posthog.groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String,+ _timestamp DateTime,+ _offset UInt64,+ is_deleted Bool+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'groups', rand());+CREATE TABLE posthog.heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));CREATE TABLE posthog.hog_invocation_results_data (team_id Int64,function_kind LowCardinality(String),@@ -167,12 +263,52 @@ CREATE TABLE posthog.message_assets_data (INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3)),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person', rand());+CREATE TABLE posthog.person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id2', rand());+CREATE TABLE posthog.person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides', rand());CREATE TABLE posthog.person_group_membership_config (team_id Int64,group_type_index UInt8,enabled UInt8,version UInt64) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_group_membership_config', '{replica}-{shard}', version) ORDER BY (team_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.person_static_cohort (+ id UUID,+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_static_cohort', rand());CREATE TABLE posthog.property_values (team_id Int64 CODEC(DoubleDelta, ZSTD(1)),property_type LowCardinality(String),@@ -306,6 +442,95 @@ CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (_partition UInt64,INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;+CREATE TABLE posthog.raw_sessions (+ team_id Int64,+ session_id_v7 UInt128,+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ pageview_count SimpleAggregateFunction(sum, Int64),+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),+ autocapture_count SimpleAggregateFunction(sum, Int64),+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),+ screen_count SimpleAggregateFunction(sum, Int64),+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))+) ENGINE = Distributed('sessions', 'posthog', 'raw_sessions', cityHash64(session_id_v7));+CREATE TABLE posthog.session_replay_events (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),+ snapshot_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),+ snapshot_mode_v2 AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.sharded_billing_usage_records (schema_version UInt8,record_id String,@@ -1253,6 +1478,17 @@ CREATE TABLE posthog.hog_invocation_results (_offset UInt64,_partition UInt64) ENGINE = Distributed('aux', 'posthog', 'hog_invocation_results_data');+CREATE TABLE posthog.log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('aux', 'posthog', 'log_entries_data');CREATE TABLE posthog.marketing_conversions_preaggregated (team_id Int64,job_id UUID,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/data.sql b/posthog/clickhouse/hcl/sql/prod-eu/data.sqlindex 49c8276cbc97..26d74a2c0de5 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/data.sql@@ -498,7 +498,7 @@ CREATE TABLE posthog.llma_metrics_daily (metric_name String,metric_value Float64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.llma_metrics_daily', '{replica}-{shard}') ORDER BY (team_id, date, metric_name) PARTITION BY toYYYYMM(date) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.log_entries_distributed (+CREATE TABLE posthog.log_entries (team_id UInt64,log_source LowCardinality(String),log_source_id String,@@ -3066,7 +3066,7 @@ CREATE TABLE posthog.heatmaps (_offset UInt64,_partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));-CREATE TABLE posthog.log_entries (+CREATE TABLE posthog.log_entries_distributed (team_id UInt64,log_source LowCardinality(String),log_source_id String,diff --git a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sqlindex 0024aebf1507..ec60f38bb2e0 100644--- a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql@@ -1,6 +1,102 @@-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.-- Full CREATE schema for the prod-us/aux node. Apply to a fresh ClickHouse to build it.+CREATE TABLE posthog.channel_definition (+ domain String,+ kind String,+ domain_type Nullable(String),+ type_if_paid Nullable(String),+ type_if_organic Nullable(String)+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'channel_definition', rand());+CREATE TABLE posthog.cohortpeople (+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ sign Int8,+ version UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohortpeople', rand());+CREATE TABLE posthog.events (+ uuid UUID,+ event String,+ properties String CODEC(ZSTD(3)),+ 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 CODEC(ZSTD(3)),+ 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)),+ 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,+ dmat_string_0 Nullable(String),+ dmat_string_1 Nullable(String),+ dmat_string_2 Nullable(String),+ dmat_string_3 Nullable(String),+ dmat_string_4 Nullable(String),+ dmat_string_5 Nullable(String),+ dmat_string_6 Nullable(String),+ dmat_string_7 Nullable(String),+ dmat_string_8 Nullable(String),+ dmat_string_9 Nullable(String),+ $group_0 String COMMENT 'column_materializer::$group_0',+ $group_1 String COMMENT 'column_materializer::$group_1',+ $group_2 String COMMENT 'column_materializer::$group_2',+ $group_3 String COMMENT 'column_materializer::$group_3',+ $group_4 String COMMENT 'column_materializer::$group_4',+ $window_id String COMMENT 'column_materializer::$window_id',+ $session_id String COMMENT 'column_materializer::$session_id',+ $session_id_uuid Nullable(UInt128),+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',+ properties_group_custom Map(String, String),+ properties_group_ai Map(String, String),+ properties_group_feature_flags Map(String, String),+ person_properties_map_custom Map(String, String),+ _timestamp DateTime,+ _offset UInt64,+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),+ consumer_breadcrumbs Array(String)+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));+CREATE TABLE posthog.groups (+ group_type_index UInt8,+ group_key String,+ created_at DateTime64(3),+ team_id Int64,+ group_properties String,+ _timestamp DateTime,+ _offset UInt64,+ is_deleted Bool+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'groups', rand());+CREATE TABLE posthog.heatmaps (+ session_id String,+ team_id Int64,+ distinct_id String,+ timestamp DateTime64(6, 'UTC'),+ x Int16,+ y Int16,+ scale_factor Int16,+ viewport_width Int16,+ viewport_height Int16,+ pointer_target_fixed Bool,+ current_url String,+ type LowCardinality(String),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));CREATE TABLE posthog.hog_invocation_results_data (team_id Int64,function_kind LowCardinality(String),@@ -167,12 +263,52 @@ CREATE TABLE posthog.message_assets_data (INDEX person_id_idx person_id TYPE bloom_filter(0.01) GRANULARITY 1,INDEX recipient_idx recipient TYPE bloom_filter(0.01) GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.message_assets_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id, action_id) PARTITION BY toYYYYMMDD(sent_at) TTL toDate(sent_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.person (+ id UUID,+ created_at DateTime64(3),+ team_id Int64,+ properties String,+ is_identified Int8,+ is_deleted Int8,+ version UInt64,+ last_seen_at Nullable(DateTime64(3)),+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person', rand());+CREATE TABLE posthog.person_distinct_id2 (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id2', rand());+CREATE TABLE posthog.person_distinct_id_overrides (+ team_id Int64,+ distinct_id String,+ person_id UUID,+ is_deleted Int8,+ version Int64,+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides', rand());CREATE TABLE posthog.person_group_membership_config (team_id Int64,group_type_index UInt8,enabled UInt8,version UInt64) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.person_group_membership_config', '{replica}-{shard}', version) ORDER BY (team_id) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.person_static_cohort (+ id UUID,+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_static_cohort', rand());CREATE TABLE posthog.property_values (team_id Int64 CODEC(DoubleDelta, ZSTD(1)),property_type LowCardinality(String),@@ -306,6 +442,95 @@ CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (_partition UInt64,INDEX kafka_timestamp_minmax_raw_error_tracking_fingerprint_issue_state _timestamp TYPE minmax GRANULARITY 3) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.raw_error_tracking_fingerprint_issue_state', '{replica}-{shard}', version) ORDER BY (team_id, fingerprint) SETTINGS index_granularity = 512;+CREATE TABLE posthog.raw_sessions (+ team_id Int64,+ session_id_v7 UInt128,+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_epik AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_qclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_sccid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),+ pageview_count SimpleAggregateFunction(sum, Int64),+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),+ autocapture_count SimpleAggregateFunction(sum, Int64),+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),+ screen_count SimpleAggregateFunction(sum, Int64),+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))+) ENGINE = Distributed('sessions', 'posthog', 'raw_sessions', cityHash64(session_id_v7));+CREATE TABLE posthog.session_replay_events (+ session_id String,+ team_id Int64,+ distinct_id String,+ min_first_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),+ max_last_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),+ first_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ click_count SimpleAggregateFunction(sum, Int64),+ keypress_count SimpleAggregateFunction(sum, Int64),+ mouse_activity_count SimpleAggregateFunction(sum, Int64),+ active_milliseconds SimpleAggregateFunction(sum, Int64),+ console_log_count SimpleAggregateFunction(sum, Int64),+ console_warn_count SimpleAggregateFunction(sum, Int64),+ console_error_count SimpleAggregateFunction(sum, Int64),+ size SimpleAggregateFunction(sum, Int64),+ message_count SimpleAggregateFunction(sum, Int64),+ event_count SimpleAggregateFunction(sum, Int64),+ _timestamp SimpleAggregateFunction(max, DateTime),+ snapshot_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ all_urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ snapshot_library AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),+ block_first_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_last_timestamps SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC'))),+ block_urls SimpleAggregateFunction(groupArrayArray, Array(String)),+ retention_period_days SimpleAggregateFunction(max, Nullable(Int64)),+ is_deleted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ ai_tags_fixed SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_tags_freeform SimpleAggregateFunction(groupUniqArrayArray, Array(String)),+ ai_highlighted SimpleAggregateFunction(max, UInt8) DEFAULT 0,+ surfacing_score SimpleAggregateFunction(max, Nullable(Float32)),+ snapshot_mode_v2 AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))+) ENGINE = Distributed('posthog', 'posthog', 'sharded_session_replay_events', sipHash64(distinct_id));CREATE TABLE posthog.sharded_billing_usage_records (schema_version UInt8,record_id String,@@ -1263,6 +1488,17 @@ CREATE TABLE posthog.ingestion_warnings_main (_offset UInt64,_partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_ingestion_warnings', rand());+CREATE TABLE posthog.log_entries (+ team_id UInt64,+ log_source LowCardinality(String),+ log_source_id String,+ instance_id String,+ timestamp DateTime64(6, 'UTC'),+ level LowCardinality(String),+ message String,+ _timestamp DateTime,+ _offset UInt64+) ENGINE = Distributed('aux', 'posthog', 'log_entries_data');CREATE TABLE posthog.marketing_conversions_preaggregated (team_id Int64,job_id UUID,diff --git a/posthog/clickhouse/hcl/sql/prod-us/data.sql b/posthog/clickhouse/hcl/sql/prod-us/data.sqlindex 15b00c809c19..d2038c249358 100644--- a/posthog/clickhouse/hcl/sql/prod-us/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/data.sql@@ -464,7 +464,7 @@ CREATE TABLE posthog.llma_metrics_daily (metric_name String,metric_value Float64) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.llma_metrics_daily', '{replica}-{shard}') ORDER BY (team_id, date, metric_name) PARTITION BY toYYYYMM(date) SETTINGS default_compression_codec = 'lz4', index_granularity = 8192;-CREATE TABLE posthog.log_entries_distributed (+CREATE TABLE posthog.log_entries (team_id UInt64,log_source LowCardinality(String),log_source_id String,@@ -2833,7 +2833,7 @@ CREATE TABLE posthog.heatmaps (_offset UInt64,_partition UInt64) ENGINE = Distributed('posthog', 'posthog', 'sharded_heatmaps', cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp)))));-CREATE TABLE posthog.log_entries (+CREATE TABLE posthog.log_entries_distributed (team_id UInt64,log_source LowCardinality(String),log_source_id String,diff --git a/posthog/clickhouse/log_entries.py b/posthog/clickhouse/log_entries.pyindex 553f5bfffc19..2198ef234bf3 100644--- a/posthog/clickhouse/log_entries.py+++ b/posthog/clickhouse/log_entries.py@@ -233,14 +233,14 @@ def LOG_ENTRIES_V3_TABLE_MV_SQL():)-# aux cluster migration (log_entries -> aux, S3-tiered)+# log_entries on the aux cluster (S3-tiered)#-# `log_entries_data` on the aux cluster is the go-forward store for log_entries: hot days on-# local disk, days older than LOG_ENTRIES_AUX_HOT_DAYS on the `cold` (S3) volume, 90 day delete.-# It is fed by a dedicated Kafka consumer (kafka_log_entries_aux + log_entries_aux_mv ->-# writable_log_entries_aux) that runs alongside the main-cluster consumer during the dual-write-# phase. `log_entries_distributed` is the reader over the aux data, present on both the aux and-# main clusters; the read cutover swaps it with `log_entries` in a follow-up migration.+# `log_entries_data` on the aux cluster stores log_entries: hot days on local disk, days older+# than LOG_ENTRIES_AUX_HOT_DAYS on the `cold` (S3) volume, 90 day delete. A dedicated Kafka+# consumer (kafka_log_entries_aux + log_entries_aux_mv -> writable_log_entries_aux) feeds it.+# `log_entries` is the reader over this data on the aux and data nodes. On the data nodes,+# `log_entries_distributed` reads `sharded_log_entries` and is the rollback target for reads.+# On the aux nodes, `log_entries_distributed` is a second name for the aux reader.## The S3 storage policy only exists on deployed cloud clusters, so the tiering clauses are# resolved per run mode and omitted locally.@@ -305,6 +305,49 @@ def LOG_ENTRIES_AUX_DISTRIBUTED_TABLE_SQL():)+def LOG_ENTRIES_AUX_READER_SQL():+ """The app-facing `log_entries` name as the aux-cluster reader over `log_entries_data`.++ On the data nodes of deployed cloud regions, the name comes from an operational+ EXCHANGE with `log_entries_distributed`, which keeps the main-cluster reader as the+ rollback target. This SQL creates the same table on the aux nodes and in fresh+ environments.+ """+ return LOG_ENTRIES_TABLE_BASE_SQL.format(+ table_name=LOG_ENTRIES_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ extra_fields=KAFKA_COLUMNS,+ engine=_log_entries_aux_distributed_engine(),+ )+++def _as_create_or_replace(sql: str) -> str:+ assert "CREATE TABLE IF NOT EXISTS" in sql+ return sql.replace("CREATE TABLE IF NOT EXISTS", "CREATE OR REPLACE TABLE", 1)+++def LOG_ENTRIES_DATA_NODE_READERS_SQL() -> list[str]:+ """The data-node read layout: `log_entries` reads aux, `log_entries_distributed` reads main.++ Both are Distributed tables that hold no data, so `CREATE OR REPLACE` declares the+ target state directly. A second run, or a run on a node that already has this layout,+ changes nothing. An EXCHANGE of the two names would swap them back on a second run.+ """+ return [+ _as_create_or_replace(LOG_ENTRIES_AUX_READER_SQL()),+ _as_create_or_replace(+ LOG_ENTRIES_TABLE_BASE_SQL.format(+ table_name=LOG_ENTRIES_AUX_DISTRIBUTED_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ extra_fields=KAFKA_COLUMNS,+ engine=Distributed(+ data_table=LOG_ENTRIES_SHARDED_TABLE, cluster=CLICKHOUSE_CLUSTER, sharding_key="rand()"+ ),+ )+ ),+ ]++def LOG_ENTRIES_AUX_WRITABLE_TABLE_SQL():return LOG_ENTRIES_TABLE_BASE_SQL.format(table_name=LOG_ENTRIES_AUX_WRITABLE_TABLE,diff --git a/posthog/clickhouse/log_entries_aux_readers.py b/posthog/clickhouse/log_entries_aux_readers.pynew file mode 100644index 000000000000..67aab19c6211--- /dev/null+++ b/posthog/clickhouse/log_entries_aux_readers.py@@ -0,0 +1,171 @@+from django.conf import settings++from posthog.clickhouse.cluster import ON_CLUSTER_CLAUSE+from posthog.clickhouse.kafka_engine import KAFKA_COLUMNS+from posthog.clickhouse.property_groups import property_groups+from posthog.clickhouse.table_engines import Distributed+from posthog.heatmaps.sql import DISTRIBUTED_HEATMAPS_TABLE_SQL+from posthog.models.event.sql import (+ EVENTS_DATA_TABLE,+ EVENTS_TABLE_BASE_SQL,+ EVENTS_TABLE_DYNAMICALLY_MATERIALIZED_COLUMNS,+ EVENTS_TABLE_PROXY_MATERIALIZED_COLUMNS,+ INSERTED_AT_COLUMN,+ KAFKA_CONSUMER_BREADCRUMBS_COLUMN,+)+from posthog.models.group.sql import GROUPS_TABLE, GROUPS_TABLE_BASE_SQL+from posthog.models.person.sql import (+ PERSON_DISTINCT_ID2_TABLE,+ PERSON_DISTINCT_ID2_TABLE_BASE_SQL,+ PERSON_DISTINCT_ID_OVERRIDES_TABLE,+ PERSON_DISTINCT_ID_OVERRIDES_TABLE_BASE_SQL,+ PERSON_STATIC_COHORT_BASE_SQL,+ PERSON_STATIC_COHORT_TABLE,+ PERSONS_TABLE,+ PERSONS_TABLE_BASE_SQL,+)+from posthog.models.raw_sessions.sessions_v2 import (+ DISTRIBUTED_RAW_SESSIONS_TABLE_SQL,+ RAW_SESSIONS_TABLE_BASE_SQL,+ TABLE_BASE_NAME as RAW_SESSIONS_TABLE,+)+from posthog.run_mode import run_mode+from posthog.session_recordings.sql.session_replay_event_sql import DISTRIBUTED_SESSION_REPLAY_EVENTS_TABLE_SQL++# Read-only Distributed readers on the aux cluster for the tables that log_entries queries join.+# `log_entries` is a Distributed table over the aux cluster, so ClickHouse runs a JOIN against it on+# the aux nodes, and the right-hand table must resolve there. Each reader forwards to the cluster that+# stores the table. Column lists come from the source templates; the env-specific mat_ columns on the+# cloud data clusters are not declared here (posthog-cloud-infra owns them).++_SINGLE_SHARD_READ_KEY = "rand()"+++def _single_shard_reader(table_name: str) -> Distributed:+ # The non-sharded replicated tables hold a full copy on every main node, so read one replica.+ return Distributed(+ data_table=table_name, cluster=settings.CLICKHOUSE_SINGLE_SHARD_CLUSTER, sharding_key=_SINGLE_SHARD_READ_KEY+ )+++def AUX_PERSON_READER_SQL() -> str:+ return PERSONS_TABLE_BASE_SQL.format(+ table_name=PERSONS_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ engine=_single_shard_reader(PERSONS_TABLE),+ extra_fields=KAFKA_COLUMNS,+ )+++def AUX_PERSON_DISTINCT_ID2_READER_SQL() -> str:+ return PERSON_DISTINCT_ID2_TABLE_BASE_SQL.format(+ table_name=PERSON_DISTINCT_ID2_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ engine=_single_shard_reader(PERSON_DISTINCT_ID2_TABLE),+ extra_fields=f"{KAFKA_COLUMNS}, _partition UInt64",+ )+++def AUX_PERSON_DISTINCT_ID_OVERRIDES_READER_SQL() -> str:+ return PERSON_DISTINCT_ID_OVERRIDES_TABLE_BASE_SQL.format(+ table_name=PERSON_DISTINCT_ID_OVERRIDES_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ engine=_single_shard_reader(PERSON_DISTINCT_ID_OVERRIDES_TABLE),+ extra_fields=f"{KAFKA_COLUMNS}, _partition UInt64",+ )+++def AUX_PERSON_STATIC_COHORT_READER_SQL() -> str:+ return PERSON_STATIC_COHORT_BASE_SQL.format(+ table_name=PERSON_STATIC_COHORT_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ engine=_single_shard_reader(PERSON_STATIC_COHORT_TABLE),+ extra_fields=KAFKA_COLUMNS,+ )+++def AUX_GROUPS_READER_SQL() -> str:+ return GROUPS_TABLE_BASE_SQL.format(+ table_name=GROUPS_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ engine=_single_shard_reader(GROUPS_TABLE),+ # is_deleted arrived by ALTER (migration 0112), so the base template does not carry it.+ extra_fields=f"{KAFKA_COLUMNS}, is_deleted Bool",+ )+++def AUX_COHORTPEOPLE_READER_SQL() -> str:+ return f"""+CREATE TABLE IF NOT EXISTS cohortpeople+(+ person_id UUID,+ cohort_id Int64,+ team_id Int64,+ sign Int8,+ version UInt64+) ENGINE = {_single_shard_reader("cohortpeople")}+"""+++def AUX_CHANNEL_DEFINITION_READER_SQL() -> str:+ return f"""+CREATE TABLE IF NOT EXISTS channel_definition+(+ domain String NOT NULL,+ kind String NOT NULL,+ domain_type String NULL,+ type_if_paid String NULL,+ type_if_organic String NULL+) ENGINE = {_single_shard_reader("channel_definition")}+"""+++def AUX_RAW_SESSIONS_READER_SQL() -> str:+ # Cloud stores raw_sessions on the sessions satellite. Local stacks keep it on the data cluster+ # behind the usual Distributed table, so the reader matches that one there.+ if not run_mode().is_deployed_cloud:+ return DISTRIBUTED_RAW_SESSIONS_TABLE_SQL(on_cluster=False)+ return RAW_SESSIONS_TABLE_BASE_SQL.format(+ table_name=RAW_SESSIONS_TABLE,+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ # The sessions satellite has no settings entry; the name is the same in every cloud env.+ engine=Distributed(data_table=RAW_SESSIONS_TABLE, cluster="sessions", sharding_key="cityHash64(session_id_v7)"),+ )+++# Migration 0198 dropped this property group from every events table, but the group stays defined+# (hidden) for migration 0197, so the shared template still emits its column.+_RETIRED_EVENTS_PROPERTY_GROUP_COLUMN = "properties_group_ai_large"+++def AUX_EVENTS_READER_SQL() -> str:+ # The main cluster's events proxy, minus the retired group, so the reader matches its remote table.+ group_pieces = list(property_groups.get_create_table_pieces("events"))+ all_groups = ", ".join(group_pieces)+ live_groups = ", ".join(piece for piece in group_pieces if _RETIRED_EVENTS_PROPERTY_GROUP_COLUMN not in piece)+ assert all_groups in EVENTS_TABLE_PROXY_MATERIALIZED_COLUMNS+ return EVENTS_TABLE_BASE_SQL.format(+ table_name="events",+ on_cluster_clause=ON_CLUSTER_CLAUSE(False),+ engine=Distributed(data_table=EVENTS_DATA_TABLE(), sharding_key="sipHash64(distinct_id)"),+ extra_fields=KAFKA_COLUMNS + INSERTED_AT_COLUMN + KAFKA_CONSUMER_BREADCRUMBS_COLUMN,+ dynamically_materialized_columns=EVENTS_TABLE_DYNAMICALLY_MATERIALIZED_COLUMNS(),+ materialized_columns=EVENTS_TABLE_PROXY_MATERIALIZED_COLUMNS.replace(all_groups, live_groups),+ indexes="",+ )+++def LOG_ENTRIES_AUX_JOIN_READERS_SQL() -> list[str]:+ return [+ AUX_EVENTS_READER_SQL(),+ DISTRIBUTED_HEATMAPS_TABLE_SQL(),+ DISTRIBUTED_SESSION_REPLAY_EVENTS_TABLE_SQL(on_cluster=False),+ AUX_PERSON_READER_SQL(),+ AUX_PERSON_DISTINCT_ID2_READER_SQL(),+ AUX_PERSON_DISTINCT_ID_OVERRIDES_READER_SQL(),+ AUX_PERSON_STATIC_COHORT_READER_SQL(),+ AUX_GROUPS_READER_SQL(),+ AUX_COHORTPEOPLE_READER_SQL(),+ AUX_CHANNEL_DEFINITION_READER_SQL(),+ AUX_RAW_SESSIONS_READER_SQL(),+ ]diff --git a/posthog/clickhouse/migrations/0352_log_entries_read_cutover.py b/posthog/clickhouse/migrations/0352_log_entries_read_cutover.pynew file mode 100644index 000000000000..320eaf6b0e5f--- /dev/null+++ b/posthog/clickhouse/migrations/0352_log_entries_read_cutover.py@@ -0,0 +1,27 @@+from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions+from posthog.clickhouse.log_entries import LOG_ENTRIES_AUX_READER_SQL, LOG_ENTRIES_DATA_NODE_READERS_SQL+from posthog.clickhouse.log_entries_aux_readers import LOG_ENTRIES_AUX_JOIN_READERS_SQL+from posthog.run_mode import run_mode++# Codifies the log_entries read cutover: `log_entries` becomes the aux-cluster+# reader, and the main-cluster reader stays under `log_entries_distributed` as the+# rollback target.+#+# On the aux nodes the app-facing name is created directly (a no-op where it exists).+# The data nodes of deployed cloud regions already have this layout, so only+# non-deployed environments set it here. The statements are CREATE OR REPLACE of the+# target layout, not an EXCHANGE, so a run on a node that already has the layout+# changes nothing, even if the run_mode() gate resolves wrongly.+#+# A JOIN against `log_entries` runs on the aux nodes, so the aux nodes also get+# Distributed readers for the joined tables. The cloud regions already have them.+operations = [+ *[run_sql_with_exceptions(sql, node_roles=[NodeRole.AUX]) for sql in LOG_ENTRIES_AUX_JOIN_READERS_SQL()],+ run_sql_with_exceptions(LOG_ENTRIES_AUX_READER_SQL(), node_roles=[NodeRole.AUX]),+]++if not run_mode().is_deployed_cloud:+ operations += [+ run_sql_with_exceptions(sql, node_roles=[NodeRole.DATA]) for sql in LOG_ENTRIES_DATA_NODE_READERS_SQL()+ ]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex 2ca10607f352..01156166b119 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0351_metrics4_names_metric_type+0352_log_entries_read_cutoverdiff --git a/posthog/clickhouse/schema.py b/posthog/clickhouse/schema.pyindex 4fef1c15f364..4f86684e6373 100644--- a/posthog/clickhouse/schema.py+++ b/posthog/clickhouse/schema.py@@ -14,6 +14,7 @@ from posthog.clickhouse.log_entries import (KAFKA_LOG_ENTRIES_TABLE_SQL,LOG_ENTRIES_AUX_DISTRIBUTED_TABLE_SQL,LOG_ENTRIES_AUX_MV_SQL,+ LOG_ENTRIES_AUX_READER_SQL,LOG_ENTRIES_AUX_WRITABLE_TABLE_SQL,LOG_ENTRIES_DATA_TABLE_SQL,LOG_ENTRIES_TABLE_MV_SQL,@@ -526,6 +527,7 @@ CREATE_DISTRIBUTED_TABLE_QUERIES = (DISTRIBUTED_PERSON_GROUP_MEMBERSHIP_CONFIG_TABLE_SQL,DISTRIBUTED_PLATFORM_ALERT_EVENTS_TABLE_SQL,LOG_ENTRIES_AUX_DISTRIBUTED_TABLE_SQL,+ LOG_ENTRIES_AUX_READER_SQL,LOG_ENTRIES_AUX_WRITABLE_TABLE_SQL,WRITABLE_EVENTS_TABLE_SQL,DISTRIBUTED_EVENTS_TABLE_SQL,diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambrindex b0502bee9a94..f32e8f6faf3e 100644--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr@@ -3498,7 +3498,7 @@'''# ----# name: test_create_table_query[log_entries]+# name: test_create_table_query[log_entries0]'''CREATE TABLE IF NOT EXISTS log_entries@@ -3533,6 +3533,38 @@'''# ---+# name: test_create_table_query[log_entries1]+ '''++ CREATE TABLE IF NOT EXISTS log_entries+ (+ team_id UInt64,+ -- The name of the service or product that generated the logs.+ -- Examples: batch_exports+ log_source LowCardinality(String),+ -- An id for the log source.+ -- Set log_source to avoid collision with ids from other log sources if the id generation is not safe.+ -- Examples: A batch export id, a cronjob id, a plugin id.+ log_source_id String,+ -- A secondary id e.g. for the instance of log_source that generated this log.+ -- This may be ommitted if log_source is a singleton.+ -- Examples: A batch export run id, a plugin_config id, a thread id, a process id, a machine id.+ instance_id String,+ -- Timestamp indicating when the log was generated.+ timestamp DateTime64(6, 'UTC'),+ -- The log level.+ -- Examples: INFO, WARNING, DEBUG, ERROR.+ level LowCardinality(String),+ -- The actual log message.+ message String++ , _timestamp DateTime+ , _offset UInt64++ ) ENGINE = Distributed('aux', 'posthog_test', 'log_entries_data')++ '''+# ---# name: test_create_table_query[log_entries_aux_mv]'''