: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): add cost planner alias columns to query_log_archive (#97761)
George Munyoro5895eb418552
diff --git a/posthog/clickhouse/hcl/golden/dev/ai_events.hcl b/posthog/clickhouse/hcl/golden/dev/ai_events.hclindex 2533cd86ef15..eb0eb5084fd8 100644--- a/posthog/clickhouse/hcl/golden/dev/ai_events.hcl+++ b/posthog/clickhouse/hcl/golden/dev/ai_events.hcl@@ -692,6 +692,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl b/posthog/clickhouse/hcl/golden/dev/auxiliary.hclindex aa35007f2542..28130424b23d 100644--- a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl@@ -1536,6 +1536,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/dev/batch_exports.hcl b/posthog/clickhouse/hcl/golden/dev/batch_exports.hclindex 000e5af18adc..18bb76bded13 100644--- a/posthog/clickhouse/hcl/golden/dev/batch_exports.hcl+++ b/posthog/clickhouse/hcl/golden/dev/batch_exports.hcl@@ -341,6 +341,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/dev/data.hcl b/posthog/clickhouse/hcl/golden/dev/data.hclindex a70ab951b6e2..481de3fb75dd 100644--- a/posthog/clickhouse/hcl/golden/dev/data.hcl+++ b/posthog/clickhouse/hcl/golden/dev/data.hcl@@ -3585,6 +3585,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/dev/logs.hcl b/posthog/clickhouse/hcl/golden/dev/logs.hclindex 24de49af943b..081a607dbe9b 100644--- a/posthog/clickhouse/hcl/golden/dev/logs.hcl+++ b/posthog/clickhouse/hcl/golden/dev/logs.hcl@@ -2743,6 +2743,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/dev/ops.hcl b/posthog/clickhouse/hcl/golden/dev/ops.hclindex 114859f2e1ec..5e10b7dde6dd 100644--- a/posthog/clickhouse/hcl/golden/dev/ops.hcl+++ b/posthog/clickhouse/hcl/golden/dev/ops.hcl@@ -777,6 +777,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"@@ -1241,6 +1253,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }column "ProfileEvents2" {type = "JSON(max_dynamic_paths=0, OSCPUVirtualTimeMicroseconds UInt64, ReadBufferFromS3Bytes UInt64, RealTimeMicroseconds UInt64, S3AbortMultipartUpload UInt64, S3Clients UInt64, S3CompleteMultipartUpload UInt64, S3CopyObject UInt64, S3CreateMultipartUpload UInt64, S3DeleteObjects UInt64, S3GetObject UInt64, S3GetObjectAttributes UInt64, S3HeadObject UInt64, S3ListObjects UInt64, S3PutObject UInt64, S3UploadPart UInt64, S3UploadPartCopy UInt64, WriteBufferFromS3Bytes UInt64)"}diff --git a/posthog/clickhouse/hcl/golden/dev/sessions.hcl b/posthog/clickhouse/hcl/golden/dev/sessions.hclindex 9087beb485a6..629759a2a622 100644--- a/posthog/clickhouse/hcl/golden/dev/sessions.hcl+++ b/posthog/clickhouse/hcl/golden/dev/sessions.hcl@@ -681,6 +681,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/ai_events.hcl b/posthog/clickhouse/hcl/golden/local-multi/ai_events.hclindex 40a52e84809d..607355a1d83e 100644--- a/posthog/clickhouse/hcl/golden/local-multi/ai_events.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/ai_events.hcl@@ -632,6 +632,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hclindex 4d29a4ce18c3..23f3a4df7d4c 100644--- a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl@@ -1579,6 +1579,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hclindex a9f9f9abe380..b48ba0a2d568 100644--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl@@ -3958,6 +3958,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hclindex 86b038d13add..ca5bd90fa317 100644--- a/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl@@ -576,6 +576,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hclindex 55e6452f4e6e..d5affb3d7b78 100644--- a/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl@@ -911,6 +911,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hclindex bd808b11d109..0fa3a346fe2b 100644--- a/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl@@ -1030,6 +1030,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl b/posthog/clickhouse/hcl/golden/local-multi/logs.hclindex 05298f60977c..865d14fe8878 100644--- a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl@@ -3317,6 +3317,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-multi/ops.hcl b/posthog/clickhouse/hcl/golden/local-multi/ops.hclindex fe59e10d1296..92aed23ddb89 100644--- a/posthog/clickhouse/hcl/golden/local-multi/ops.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/ops.hcl@@ -394,6 +394,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"@@ -857,6 +869,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "replicated_merge_tree" {zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"replica_name = "{replica}-{shard}"diff --git a/posthog/clickhouse/hcl/golden/local-multi/sessions.hcl b/posthog/clickhouse/hcl/golden/local-multi/sessions.hclindex 850221fefe59..a4b1954009e5 100644--- a/posthog/clickhouse/hcl/golden/local-multi/sessions.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/sessions.hcl@@ -341,6 +341,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hclindex 7dd1fada0a4d..63591521903d 100644--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl@@ -9275,6 +9275,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"@@ -13095,6 +13107,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "replicated_merge_tree" {zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"replica_name = "{replica}-{shard}"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hcl b/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hclindex 8c12d55e1506..6abcba8011a0 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hcl@@ -692,6 +692,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hclindex e07d1cc23f59..94209fb06645 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl@@ -1536,6 +1536,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hcl b/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hclindex 6be4c402ec14..1b8452e871a6 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hcl@@ -341,6 +341,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl b/posthog/clickhouse/hcl/golden/prod-eu/data.hclindex dee868702aaa..44149986edea 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/data.hcl@@ -4195,6 +4195,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl b/posthog/clickhouse/hcl/golden/prod-eu/logs.hclindex e6d08870b323..7b3bdf1201e4 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl@@ -2903,6 +2903,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl b/posthog/clickhouse/hcl/golden/prod-eu/ops.hclindex 00d8abded32e..e2e8c0ff4dea 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl@@ -736,6 +736,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"@@ -1298,6 +1310,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "replicated_merge_tree" {zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"replica_name = "{replica}-{shard}"diff --git a/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl b/posthog/clickhouse/hcl/golden/prod-eu/sessions.hclindex e2acb0aab18f..9192b4baf7e0 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl@@ -677,6 +677,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-us/ai_events.hcl b/posthog/clickhouse/hcl/golden/prod-us/ai_events.hclindex 8c12d55e1506..6abcba8011a0 100644--- a/posthog/clickhouse/hcl/golden/prod-us/ai_events.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/ai_events.hcl@@ -692,6 +692,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hclindex 63efe0c67439..dfb065fe4942 100644--- a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl@@ -1574,6 +1574,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hcl b/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hclindex 000e5af18adc..18bb76bded13 100644--- a/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hcl@@ -341,6 +341,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-us/data.hcl b/posthog/clickhouse/hcl/golden/prod-us/data.hclindex 36ffcb2a7d16..63c4dd2069ab 100644--- a/posthog/clickhouse/hcl/golden/prod-us/data.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/data.hcl@@ -3990,6 +3990,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl b/posthog/clickhouse/hcl/golden/prod-us/logs.hclindex 8b3c67b478b9..32eb973499e4 100644--- a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl@@ -2903,6 +2903,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/golden/prod-us/ops.hcl b/posthog/clickhouse/hcl/golden/prod-us/ops.hclindex 5c9a4d65b33f..60b1110869fe 100644--- a/posthog/clickhouse/hcl/golden/prod-us/ops.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/ops.hcl@@ -820,6 +820,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"@@ -1379,6 +1391,18 @@ SQLtype = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }column "ProfileEvents2" {type = "JSON(max_dynamic_paths=0, OSCPUVirtualTimeMicroseconds UInt64, ReadBufferFromS3Bytes UInt64, RealTimeMicroseconds UInt64, S3AbortMultipartUpload UInt64, S3Clients UInt64, S3CompleteMultipartUpload UInt64, S3CopyObject UInt64, S3CreateMultipartUpload UInt64, S3DeleteObjects UInt64, S3GetObject UInt64, S3GetObjectAttributes UInt64, S3HeadObject UInt64, S3ListObjects UInt64, S3PutObject UInt64, S3UploadPart UInt64, S3UploadPartCopy UInt64, WriteBufferFromS3Bytes UInt64)"}diff --git a/posthog/clickhouse/hcl/golden/prod-us/sessions.hcl b/posthog/clickhouse/hcl/golden/prod-us/sessions.hclindex 0b19439c0b0c..0d1ee678beb8 100644--- a/posthog/clickhouse/hcl/golden/prod-us/sessions.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/sessions.hcl@@ -681,6 +681,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/roles/ops/shared/core.hcl b/posthog/clickhouse/hcl/roles/ops/shared/core.hclindex 5c79f165c43c..05006ee0d814 100644--- a/posthog/clickhouse/hcl/roles/ops/shared/core.hcl+++ b/posthog/clickhouse/hcl/roles/ops/shared/core.hcl@@ -508,6 +508,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "replicated_merge_tree" {zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"replica_name = "{replica}-{shard}"diff --git a/posthog/clickhouse/hcl/roles/shared/qla.hcl b/posthog/clickhouse/hcl/roles/shared/qla.hclindex 69c33df6dde1..b70cbc6de840 100644--- a/posthog/clickhouse/hcl/roles/shared/qla.hcl+++ b/posthog/clickhouse/hcl/roles/shared/qla.hcl@@ -343,6 +343,18 @@ database "posthog" {type = "String"alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"}+ column "lc_plan_fingerprint" {+ type = "String"+ alias = "ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')"+ }+ column "lc_estimated_rows" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)"+ }+ column "lc_estimated_bytes" {+ type = "Int64"+ alias = "ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)"+ }engine "distributed" {cluster_name = "ops"remote_database = "posthog"diff --git a/posthog/clickhouse/hcl/sql/dev/ai_events.sql b/posthog/clickhouse/hcl/sql/dev/ai_events.sqlindex aef22d4618cd..c27ca14be081 100644--- a/posthog/clickhouse/hcl/sql/dev/ai_events.sql+++ b/posthog/clickhouse/hcl/sql/dev/ai_events.sql@@ -197,7 +197,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.writable_query_log_archive (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql b/posthog/clickhouse/hcl/sql/dev/auxiliary.sqlindex f154ac370965..2dde5bad92d9 100644--- a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/dev/auxiliary.sql@@ -283,7 +283,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/dev/batch_exports.sql b/posthog/clickhouse/hcl/sql/dev/batch_exports.sqlindex 4f3212e25c2d..590382352bc4 100644--- a/posthog/clickhouse/hcl/sql/dev/batch_exports.sql+++ b/posthog/clickhouse/hcl/sql/dev/batch_exports.sql@@ -94,7 +94,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.sharded_events_recent (uuid UUID,diff --git a/posthog/clickhouse/hcl/sql/dev/data.sql b/posthog/clickhouse/hcl/sql/dev/data.sqlindex ccb5507f1360..3c6ba8013424 100644--- a/posthog/clickhouse/hcl/sql/dev/data.sql+++ b/posthog/clickhouse/hcl/sql/dev/data.sql@@ -760,7 +760,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.session_replay_features (session_id String,diff --git a/posthog/clickhouse/hcl/sql/dev/logs.sql b/posthog/clickhouse/hcl/sql/dev/logs.sqlindex 6e083351f045..fef421be8669 100644--- a/posthog/clickhouse/hcl/sql/dev/logs.sql+++ b/posthog/clickhouse/hcl/sql/dev/logs.sql@@ -709,7 +709,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.trace_attributes (team_id Int32,diff --git a/posthog/clickhouse/hcl/sql/dev/ops.sql b/posthog/clickhouse/hcl/sql/dev/ops.sqlindex 655af8b6e190..b4decd5daab8 100644--- a/posthog/clickhouse/hcl/sql/dev/ops.sql+++ b/posthog/clickhouse/hcl/sql/dev/ops.sql@@ -200,6 +200,9 @@ CREATE TABLE posthog.sharded_query_log_archive (lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0),ProfileEvents2 JSON(max_dynamic_paths=0, OSCPUVirtualTimeMicroseconds UInt64, ReadBufferFromS3Bytes UInt64, RealTimeMicroseconds UInt64, S3AbortMultipartUpload UInt64, S3Clients UInt64, S3CompleteMultipartUpload UInt64, S3CopyObject UInt64, S3CreateMultipartUpload UInt64, S3DeleteObjects UInt64, S3GetObject UInt64, S3GetObjectAttributes UInt64, S3HeadObject UInt64, S3ListObjects UInt64, S3PutObject UInt64, S3UploadPart UInt64, S3UploadPartCopy UInt64, WriteBufferFromS3Bytes UInt64)) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', storage_policy = 's3_tiered';CREATE TABLE posthog.sharded_tophog (@@ -449,7 +452,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.query_log_archive_buffer (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/dev/sessions.sql b/posthog/clickhouse/hcl/sql/dev/sessions.sqlindex 2bf1337b7a09..dcdef34f4f99 100644--- a/posthog/clickhouse/hcl/sql/dev/sessions.sql+++ b/posthog/clickhouse/hcl/sql/dev/sessions.sql@@ -194,7 +194,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_sessions (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/local-multi/ai_events.sql b/posthog/clickhouse/hcl/sql/local-multi/ai_events.sqlindex 1191ec992bb0..03dbb4ae28e3 100644--- a/posthog/clickhouse/hcl/sql/local-multi/ai_events.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/ai_events.sql@@ -125,7 +125,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.sharded_ai_events (uuid UUID,diff --git a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sqlindex 74857317bc6b..a05e3c938810 100644--- a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql@@ -297,7 +297,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sqlindex 8808edeb4280..1b4f953509a9 100644--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql@@ -762,7 +762,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.query_log_archive_v2 (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sqlindex 260140a2ce2a..503e421f88dc 100644--- a/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql@@ -160,7 +160,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.writable_events_json (uuid UUID,diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sqlindex 3c00b6ef1fe5..e5d6cb4d0a3b 100644--- a/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql@@ -261,7 +261,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.writable_app_metrics2 (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sqlindex dda03bcc414a..f561988e6af0 100644--- a/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql@@ -297,7 +297,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.writable_app_metrics (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/local-multi/logs.sql b/posthog/clickhouse/hcl/sql/local-multi/logs.sqlindex 3ab6b1bc37ca..a7b6e868b12d 100644--- a/posthog/clickhouse/hcl/sql/local-multi/logs.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/logs.sql@@ -823,7 +823,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.trace_attributes (team_id Int32,diff --git a/posthog/clickhouse/hcl/sql/local-multi/ops.sql b/posthog/clickhouse/hcl/sql/local-multi/ops.sqlindex fda25f6d31ea..337c44e3ab47 100644--- a/posthog/clickhouse/hcl/sql/local-multi/ops.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/ops.sql@@ -110,7 +110,10 @@ CREATE TABLE posthog.sharded_query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets';CREATE VIEW posthog.custom_metrics_backups AS WITH['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,@@ -307,7 +310,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.query_log_archive_buffer (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/local-multi/sessions.sql b/posthog/clickhouse/hcl/sql/local-multi/sessions.sqlindex 402526528ef8..eae2dc1c8ea2 100644--- a/posthog/clickhouse/hcl/sql/local-multi/sessions.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/sessions.sql@@ -94,7 +94,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.writable_query_log_archive (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sqlindex 1e24e86faa9e..80744b58f6cb 100644--- a/posthog/clickhouse/hcl/sql/local-single/all.sql+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql@@ -2641,7 +2641,10 @@ CREATE TABLE posthog.sharded_query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets';CREATE TABLE posthog.sharded_query_log_archive_old (hostname LowCardinality(String),@@ -7265,7 +7268,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.query_log_archive_buffer (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sql b/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sqlindex 5f219f9fb3c6..37e2f0683dbc 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sql@@ -197,7 +197,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.writable_query_log_archive (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sqlindex 1b96a47c4f82..ca986f68b405 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql@@ -283,7 +283,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sql b/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sqlindex eb14568af8bd..30dfa433a1d2 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sql@@ -94,7 +94,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.sharded_events_recent (uuid UUID,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/data.sql b/posthog/clickhouse/hcl/sql/prod-eu/data.sqlindex 27f87c81ec77..388268436dff 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/data.sql@@ -1011,7 +1011,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_sessions (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql b/posthog/clickhouse/hcl/sql/prod-eu/logs.sqlindex 184b1ce5cf21..4a5cb9b6b978 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql@@ -755,7 +755,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.trace_attributes (team_id Int32,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/ops.sql b/posthog/clickhouse/hcl/sql/prod-eu/ops.sqlindex 4753d9aa5b78..db046b59b68a 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/ops.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/ops.sql@@ -234,7 +234,10 @@ CREATE TABLE posthog.sharded_query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, max_replicated_merges_in_queue = 6, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', parts_to_delay_insert = 1000, parts_to_throw_insert = 3000, prefer_fetch_merged_part_size_threshold = 1, prefer_fetch_merged_part_time_threshold = 60;CREATE TABLE posthog.sharded_tophog (timestamp DateTime64(6, 'UTC'),@@ -450,7 +453,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.query_log_archive_buffer (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql b/posthog/clickhouse/hcl/sql/prod-eu/sessions.sqlindex 1eaab798fb50..80218dcbc21c 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql@@ -194,7 +194,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_sessions (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/prod-us/ai_events.sql b/posthog/clickhouse/hcl/sql/prod-us/ai_events.sqlindex a2b1789c4744..24f3d44fc1ce 100644--- a/posthog/clickhouse/hcl/sql/prod-us/ai_events.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/ai_events.sql@@ -197,7 +197,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.writable_query_log_archive (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sqlindex f654c57928ba..2d954a451260 100644--- a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql@@ -283,7 +283,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_error_tracking_fingerprint_issue_state (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sql b/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sqlindex b6ca768614af..43f7b7fbb761 100644--- a/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sql@@ -94,7 +94,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.sharded_events_recent (uuid UUID,diff --git a/posthog/clickhouse/hcl/sql/prod-us/data.sql b/posthog/clickhouse/hcl/sql/prod-us/data.sqlindex 4e30fb9266ef..73e55df9fe42 100644--- a/posthog/clickhouse/hcl/sql/prod-us/data.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/data.sql@@ -880,7 +880,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_sessions (team_id Int64,diff --git a/posthog/clickhouse/hcl/sql/prod-us/logs.sql b/posthog/clickhouse/hcl/sql/prod-us/logs.sqlindex fe76b0051360..f72701107923 100644--- a/posthog/clickhouse/hcl/sql/prod-us/logs.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/logs.sql@@ -755,7 +755,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.trace_attributes (team_id Int32,diff --git a/posthog/clickhouse/hcl/sql/prod-us/ops.sql b/posthog/clickhouse/hcl/sql/prod-us/ops.sqlindex a4dc7f6d299a..62f439c5e083 100644--- a/posthog/clickhouse/hcl/sql/prod-us/ops.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/ops.sql@@ -262,6 +262,9 @@ CREATE TABLE posthog.sharded_query_log_archive (lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0),ProfileEvents2 JSON(max_dynamic_paths=0, OSCPUVirtualTimeMicroseconds UInt64, ReadBufferFromS3Bytes UInt64, RealTimeMicroseconds UInt64, S3AbortMultipartUpload UInt64, S3Clients UInt64, S3CompleteMultipartUpload UInt64, S3CopyObject UInt64, S3CreateMultipartUpload UInt64, S3DeleteObjects UInt64, S3GetObject UInt64, S3GetObjectAttributes UInt64, S3HeadObject UInt64, S3ListObjects UInt64, S3PutObject UInt64, S3UploadPart UInt64, S3UploadPartCopy UInt64, WriteBufferFromS3Bytes UInt64)) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', storage_policy = 's3_tiered';CREATE TABLE posthog.sharded_tophog (@@ -478,7 +481,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.query_log_archive_buffer (hostname LowCardinality(String),diff --git a/posthog/clickhouse/hcl/sql/prod-us/sessions.sql b/posthog/clickhouse/hcl/sql/prod-us/sessions.sqlindex 188bf65d6ebf..256bf979f7c9 100644--- a/posthog/clickhouse/hcl/sql/prod-us/sessions.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/sessions.sql@@ -194,7 +194,10 @@ CREATE TABLE posthog.query_log_archive (lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),+ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');CREATE TABLE posthog.raw_sessions (team_id Int64,diff --git a/posthog/clickhouse/migrations/0337_query_log_archive_cost_planner_aliases.py b/posthog/clickhouse/migrations/0337_query_log_archive_cost_planner_aliases.pynew file mode 100644index 000000000000..7ef7692caff7--- /dev/null+++ b/posthog/clickhouse/migrations/0337_query_log_archive_cost_planner_aliases.py@@ -0,0 +1,30 @@+"""AUTO-GENERATED from the declarative HCL by posthog/clickhouse/hcl/codegen/gen_migration.py.+Placement (node_roles) is derived from the node composition manifest; review before committing.+"""++from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions+from posthog.clickhouse.query_log_archive import (+ QUERY_LOG_ARCHIVE_ADD_COST_PLANNER_ALIASES_SQL,+ QUERY_LOG_ARCHIVE_DATA_TABLE,+ SHARDED_QUERY_LOG_ARCHIVE_TABLE,+)++# Read-time ALIAS columns over log_comment paths the HogQL cost planner emits as query tags. The JSON+# column already stores those paths, so this is metadata only: no data is rewritten and the writable,+# buffer and MV are untouched because they carry physical columns only.+operations = [+ run_sql_with_exceptions(+ QUERY_LOG_ARCHIVE_ADD_COST_PLANNER_ALIASES_SQL(SHARDED_QUERY_LOG_ARCHIVE_TABLE),+ node_roles=[NodeRole.OPS],+ sharded=False,+ is_alter_on_replicated_table=True,+ ),+ # The Distributed read table was created on every node (0273), so it converges on every node too.+ run_sql_with_exceptions(+ QUERY_LOG_ARCHIVE_ADD_COST_PLANNER_ALIASES_SQL(QUERY_LOG_ARCHIVE_DATA_TABLE),+ node_roles=[NodeRole.ALL],+ sharded=False,+ is_alter_on_replicated_table=False,+ ),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex eb94c277d267..5b754f130a71 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0336_metrics4_view+0337_query_log_archive_cost_planner_aliasesdiff --git a/posthog/clickhouse/query_log_archive.py b/posthog/clickhouse/query_log_archive.pyindex 65dadc10b7a4..8e859627114c 100644--- a/posthog/clickhouse/query_log_archive.py+++ b/posthog/clickhouse/query_log_archive.py@@ -609,6 +609,23 @@ _QUERY_LOG_ARCHIVE_PHYSICAL_COLUMNS = """log_comment {log_comment_type},ProfileEvents Map(String, UInt64)""".format(log_comment_type=LOG_COMMENT_JSON_TYPE)+# HogQL cost planner tags (posthog/hogql/cost/). These keys have no type hint in LOG_COMMENT_JSON_TYPE, so the+# JSON column keeps them as Dynamic paths that read as NULL when absent. dynamicElement extracts the typed value+# and ifNull gives the same '' / 0 default the hinted lc_* columns have. It is the function form of the `.:Type`+# subcolumn syntax, which the HCL introspection parser (hclexp) cannot read back from SHOW CREATE TABLE.+_COST_PLANNER_ALIAS_COLUMNS = (+ "lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), '')",+ "lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0)",+ "lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)",+)+++def QUERY_LOG_ARCHIVE_ADD_COST_PLANNER_ALIASES_SQL(table=QUERY_LOG_ARCHIVE_DATA_TABLE):+ return f"ALTER TABLE {table} " + ", ".join(+ f"ADD COLUMN IF NOT EXISTS {column}" for column in _COST_PLANNER_ALIAS_COLUMNS+ )++# Read-time aliases. lc_* read the curated JSON subset; ProfileEvents_* read the# raw map; exception_name keeps its derived form. The lc_query* / lc_modifiers# aliases reproduce the previous MV logic (source preference + is_initial_query@@ -685,7 +702,9 @@ _QUERY_LOG_ARCHIVE_ALIAS_COLUMNS = """lc_dagster__run_id String ALIAS log_comment.`dagster.run_id`::String,lc_dagster__owner String ALIAS log_comment.`dagster.tags.owner`::String,- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"""+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),++ {cost_planner_aliases}""".format(cost_planner_aliases=",\n ".join(_COST_PLANNER_ALIAS_COLUMNS))_QUERY_LOG_ARCHIVE_OPS_TABLE_CLAUSES = """PARTITION BY toYYYYMM(event_date)diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambrindex 395934a725b9..b33276d3234b 100644--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr@@ -6458,7 +6458,11 @@lc_dagster__run_id String ALIAS log_comment.`dagster.run_id`::String,lc_dagster__owner String ALIAS log_comment.`dagster.tags.owner`::String,- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),++ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = Distributed('ops', 'posthog_test', 'sharded_query_log_archive')'''# ---@@ -8723,7 +8727,11 @@lc_dagster__run_id String ALIAS log_comment.`dagster.run_id`::String,lc_dagster__owner String ALIAS log_comment.`dagster.tags.owner`::String,- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),++ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.sharded_query_log_archive', '{replica}-{shard}')PARTITION BY toYYYYMM(event_date)ORDER BY (team_id, event_date, event_time, query_id)@@ -14393,7 +14401,11 @@lc_dagster__run_id String ALIAS log_comment.`dagster.run_id`::String,lc_dagster__owner String ALIAS log_comment.`dagster.tags.owner`::String,- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')+ lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),++ lc_plan_fingerprint String ALIAS ifNull(dynamicElement(log_comment.plan_fingerprint, 'String'), ''),+ lc_estimated_rows Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_rows, 'Int64'), 0),+ lc_estimated_bytes Int64 ALIAS ifNull(dynamicElement(log_comment.estimated_bytes, 'Int64'), 0)) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.sharded_query_log_archive', '{replica}-{shard}')PARTITION BY toYYYYMM(event_date)ORDER BY (team_id, event_date, event_time, query_id)diff --git a/posthog/clickhouse/test/test_query_log_archive_aliases.py b/posthog/clickhouse/test/test_query_log_archive_aliases.pynew file mode 100644index 000000000000..29e125c99c86--- /dev/null+++ b/posthog/clickhouse/test/test_query_log_archive_aliases.py@@ -0,0 +1,69 @@+import json++from posthog.test.base import ClickhouseTestMixin++from django.test import SimpleTestCase++from parameterized import parameterized++from posthog.clickhouse.client import sync_execute+from posthog.clickhouse.query_log_archive import QUERY_LOG_ARCHIVE_OPS_TABLE_SQL++TABLE = "test_query_log_archive_aliases"+++class TestQueryLogArchiveCostPlannerAliases(ClickhouseTestMixin, SimpleTestCase):+ @classmethod+ def setUpClass(cls) -> None:+ super().setUpClass()+ sync_execute(f"DROP TABLE IF EXISTS {TABLE} SYNC")+ sync_execute(+ QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(table_name=TABLE, engine="MergeTree", include_table_clauses=False)+ + " ORDER BY (team_id, event_date)"+ )++ @classmethod+ def tearDownClass(cls) -> None:+ try:+ sync_execute(f"DROP TABLE IF EXISTS {TABLE} SYNC")+ finally:+ super().tearDownClass()++ def _insert(self, query_id: str, log_comment: dict) -> None:+ sync_execute(+ f"INSERT INTO {TABLE} (query_id, type, event_date, event_time, team_id, log_comment) "+ "VALUES (%(query_id)s, 'QueryFinish', today(), now(), %(team_id)s, %(log_comment)s)",+ {"query_id": query_id, "team_id": log_comment["team_id"], "log_comment": json.dumps(log_comment)},+ )++ def _read(self, query_id: str) -> tuple[str, int, int]:+ [row] = sync_execute(+ f"SELECT lc_plan_fingerprint, lc_estimated_rows, lc_estimated_bytes FROM {TABLE} WHERE query_id = %(q)s",+ {"q": query_id},+ )+ return row++ @parameterized.expand(+ [+ (+ "present",+ {+ "team_id": 1,+ "plan_fingerprint": "e8ff93df7e4e989a",+ "estimated_rows": 1_800_000,+ "estimated_bytes": 9_000,+ },+ ("e8ff93df7e4e989a", 1_800_000, 9_000),+ ),+ ("absent", {"team_id": 1, "query_type": "HogQLQuery"}, ("", 0, 0)),+ (+ "large_int_stays_int64",+ {"team_id": 1, "plan_fingerprint": "ab", "estimated_rows": 1_800_000_000_000, "estimated_bytes": 0},+ ("ab", 1_800_000_000_000, 0),+ ),+ ]+ )+ def test_aliases_read_the_tag_values_back(self, name, log_comment, expected):+ self._insert(name, log_comment)++ assert self._read(name) == expected