Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(clickhouse): match system.processes enum types on clickhouse 26.9 (#114759)

Rory Shanks48ab5ea58143
diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hcl
index e35d9de756a7..9b1258aa1b8d 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl
@@ -958,7 +958,7 @@ database "posthog" {
type = "UInt16"
}
column "interface" {
- type = "UInt8"
+ type = "Enum8('Unknown'=0, 'TCP'=1, 'HTTP'=2, 'gRPC'=3, 'MySQL'=4, 'PostgreSQL'=5, 'Local'=6, 'TCP_Interserver'=7, 'Prometheus'=8, 'Background'=9, 'ArrowFlight'=10)"
}
column "os_user" {
type = "String"
@@ -988,7 +988,7 @@ database "posthog" {
type = "LowCardinality(String)"
}
column "http_method" {
- type = "UInt8"
+ type = "Enum8('UNKNOWN'=0, 'GET'=1, 'POST'=2, 'OPTIONS'=3, 'PUT'=4, 'DELETE'=5, 'HEAD'=6)"
}
column "http_user_agent" {
type = "String"
diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hcl
index ce86ea265fd3..143fa76e50bd 100644
--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl
+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl
@@ -985,7 +985,7 @@ database "posthog" {
type = "UInt16"
}
column "interface" {
- type = "UInt8"
+ type = "Enum8('Unknown'=0, 'TCP'=1, 'HTTP'=2, 'gRPC'=3, 'MySQL'=4, 'PostgreSQL'=5, 'Local'=6, 'TCP_Interserver'=7, 'Prometheus'=8, 'Background'=9, 'ArrowFlight'=10)"
}
column "os_user" {
type = "String"
@@ -1015,7 +1015,7 @@ database "posthog" {
type = "LowCardinality(String)"
}
column "http_method" {
- type = "UInt8"
+ type = "Enum8('UNKNOWN'=0, 'GET'=1, 'POST'=2, 'OPTIONS'=3, 'PUT'=4, 'DELETE'=5, 'HEAD'=6)"
}
column "http_user_agent" {
type = "String"
diff --git a/posthog/clickhouse/hcl/roles/data/local/patches.hcl b/posthog/clickhouse/hcl/roles/data/local/patches.hcl
index 847b4343df46..5f3caab5ea71 100644
--- a/posthog/clickhouse/hcl/roles/data/local/patches.hcl
+++ b/posthog/clickhouse/hcl/roles/data/local/patches.hcl
@@ -179,4 +179,15 @@ database "posthog" {
sharding_key = "sipHash64(distinct_id)"
}
}
+
+ # ClickHouse 26.9 types these system.processes columns as Enum8; the prod envs
+ # still run a version that types them as UInt8.
+ patch_table "distributed_system_processes" {
+ modify_column "interface" {
+ type = "Enum8('Unknown'=0, 'TCP'=1, 'HTTP'=2, 'gRPC'=3, 'MySQL'=4, 'PostgreSQL'=5, 'Local'=6, 'TCP_Interserver'=7, 'Prometheus'=8, 'Background'=9, 'ArrowFlight'=10)"
+ }
+ modify_column "http_method" {
+ type = "Enum8('UNKNOWN'=0, 'GET'=1, 'POST'=2, 'OPTIONS'=3, 'PUT'=4, 'DELETE'=5, 'HEAD'=6)"
+ }
+ }
}
diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sql
index bd496ab5536d..253431a32775 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql
@@ -171,7 +171,7 @@ CREATE TABLE posthog.distributed_system_processes (
initial_query_id String,
initial_address IPv6,
initial_port UInt16,
- interface UInt8,
+ interface Enum8('Unknown'=0, 'TCP'=1, 'HTTP'=2, 'gRPC'=3, 'MySQL'=4, 'PostgreSQL'=5, 'Local'=6, 'TCP_Interserver'=7, 'Prometheus'=8, 'Background'=9, 'ArrowFlight'=10),
os_user String,
client_hostname String,
client_name String,
@@ -181,7 +181,7 @@ CREATE TABLE posthog.distributed_system_processes (
client_version_minor UInt64,
client_version_patch UInt64,
client_agent LowCardinality(String),
- http_method UInt8,
+ http_method Enum8('UNKNOWN'=0, 'GET'=1, 'POST'=2, 'OPTIONS'=3, 'PUT'=4, 'DELETE'=5, 'HEAD'=6),
http_user_agent String,
http_referer String,
forwarded_for String,
diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sql
index be3d272feecb..438527e97085 100644
--- a/posthog/clickhouse/hcl/sql/local-single/all.sql
+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql
@@ -68,7 +68,7 @@ CREATE TABLE posthog.distributed_system_processes (
initial_query_id String,
initial_address IPv6,
initial_port UInt16,
- interface UInt8,
+ interface Enum8('Unknown'=0, 'TCP'=1, 'HTTP'=2, 'gRPC'=3, 'MySQL'=4, 'PostgreSQL'=5, 'Local'=6, 'TCP_Interserver'=7, 'Prometheus'=8, 'Background'=9, 'ArrowFlight'=10),
os_user String,
client_hostname String,
client_name String,
@@ -78,7 +78,7 @@ CREATE TABLE posthog.distributed_system_processes (
client_version_minor UInt64,
client_version_patch UInt64,
client_agent LowCardinality(String),
- http_method UInt8,
+ http_method Enum8('UNKNOWN'=0, 'GET'=1, 'POST'=2, 'OPTIONS'=3, 'PUT'=4, 'DELETE'=5, 'HEAD'=6),
http_user_agent String,
http_referer String,
forwarded_for String,