: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): rebuild query_log_archive on JSON-backed schema (#62378)
Paweł Szczur7ecc9d6b6dd3
diff --git a/posthog/clickhouse/migrations/0273_query_log_archive_ops_json.py b/posthog/clickhouse/migrations/0273_query_log_archive_ops_json.pynew file mode 100644index 000000000000..ec1dee05342d--- /dev/null+++ b/posthog/clickhouse/migrations/0273_query_log_archive_ops_json.py@@ -0,0 +1,78 @@+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 (+ DISTRIBUTED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ QUERY_LOG_ARCHIVE_DATA_TABLE,+ QUERY_LOG_ARCHIVE_OPS_MV,+ QUERY_LOG_ARCHIVE_OPS_MV_SQL,+ SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ SHARDED_QUERY_LOG_ARCHIVE_TABLE,+ WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ WRITABLE_QUERY_LOG_ARCHIVE_TABLE,+)++# Rebuild query_log_archive as a JSON-backed data table living on the OPS cluster:+# - sharded_query_log_archive : OPS data table, stores log_comment as a curated JSON column and+# ProfileEvents as the raw Map; every lc_* / ProfileEvents_* column is a read-time ALIAS.+# - query_log_archive : Distributed read table over ops.sharded_query_log_archive, everywhere.+# - writable_query_log_archive: Distributed write table (physical columns only), everywhere.+# - ops_query_log_archive_mv : slim MV (system.query_log -> writable), on every cluster.+#+# This migration is idempotent and converges TWO divergent starting states:+# (A) Production, set up by hand: query_log_archive is the *data table* on OPS, writable_query_log_archive+# and ops_query_log_archive_mv already exist (old schema, all lc_*/ProfileEvents_* physical).+# (B) Repo migration history (0196+): sharded_query_log_archive is the data table, with+# sharded_query_log_archive_mv / dist_query_log_archive_mv MVs.+# The old OPS data table is renamed to query_log_archive_old (NOT dropped) so it can be backfilled into+# the new table manually; the ClickHouse team drops it afterwards.++# Every cluster produces its own system.query_log, archives it into OPS via the writable table, and can+# read it back through the Distributed query_log_archive.+ALL_ROLES = [+ NodeRole.DATA,+ NodeRole.ENDPOINTS,+ NodeRole.AUX,+ NodeRole.AI_EVENTS,+ NodeRole.SESSIONS,+ NodeRole.OPS,+]+QUERY_LOG_ARCHIVE_OLD_TABLE = "query_log_archive_old" # renamed OPS data table, kept for manual backfill+SHARDED_OLD_TABLE = "sharded_query_log_archive_old" # renamed repo-history data table (state B)++# Previous-generation MV names retired here (prod uses ops_query_log_archive_mv; history uses the others).+OLD_SHARDED_MV = "sharded_query_log_archive_mv"+OLD_DIST_MV = "dist_query_log_archive_mv"++operations = [+ # ---------- A. Stop the old write path (MVs hold no data) ----------+ run_sql_with_exceptions(f"DROP TABLE IF EXISTS {QUERY_LOG_ARCHIVE_OPS_MV}", node_roles=ALL_ROLES),+ run_sql_with_exceptions(f"DROP TABLE IF EXISTS {OLD_SHARDED_MV}", node_roles=[NodeRole.DATA]),+ run_sql_with_exceptions(f"DROP TABLE IF EXISTS {OLD_DIST_MV}", node_roles=[NodeRole.ENDPOINTS]),+ # ---------- B. Move the old populated data tables aside (no data dropped) ----------+ # State B: the repo-history sharded data table collides with the new JSON table name.+ run_sql_with_exceptions(+ f"RENAME TABLE IF EXISTS {SHARDED_QUERY_LOG_ARCHIVE_TABLE} TO {SHARDED_OLD_TABLE}",+ node_roles=[NodeRole.DATA],+ ),+ # State A: the production OPS data table. Kept as query_log_archive_old for the manual backfill.+ run_sql_with_exceptions(+ f"RENAME TABLE IF EXISTS {QUERY_LOG_ARCHIVE_DATA_TABLE} TO {QUERY_LOG_ARCHIVE_OLD_TABLE}",+ node_roles=[NodeRole.OPS],+ ),+ # ---------- C. New JSON-backed data table on OPS ----------+ run_sql_with_exceptions(SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(), node_roles=[NodeRole.OPS]),+ # ---------- D. Writable Distributed (physical columns only) -> ops.sharded, on every cluster ----------+ # Drop first to replace prod's existing old-schema writable (a no-data Distributed).+ run_sql_with_exceptions(f"DROP TABLE IF EXISTS {WRITABLE_QUERY_LOG_ARCHIVE_TABLE}", node_roles=ALL_ROLES),+ run_sql_with_exceptions(WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(), node_roles=ALL_ROLES),+ # ---------- E. Slim MV (system.query_log -> writable), on every cluster ----------+ run_sql_with_exceptions(+ QUERY_LOG_ARCHIVE_OPS_MV_SQL(view_name=QUERY_LOG_ARCHIVE_OPS_MV, dest_table=WRITABLE_QUERY_LOG_ARCHIVE_TABLE),+ node_roles=ALL_ROLES,+ ),+ # ---------- F. Read Distributed query_log_archive -> ops.sharded, on EVERY node ----------+ # Created everywhere so query_log_archive is queryable from any node. Safe to drop on every node:+ # the only place it is a populated data table is OPS, already renamed aside in B.+ run_sql_with_exceptions(f"DROP TABLE IF EXISTS {QUERY_LOG_ARCHIVE_DATA_TABLE}", node_roles=[NodeRole.ALL]),+ run_sql_with_exceptions(DISTRIBUTED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(), node_roles=[NodeRole.ALL]),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex 9bda31f62fe0..c0a98f4e36a6 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0272_web_dimensional_preaggregated+0273_query_log_archive_ops_json\ No newline at end of filediff --git a/posthog/clickhouse/query_log_archive.py b/posthog/clickhouse/query_log_archive.pyindex f74cb58ff9a5..1d54d0bb5f06 100644--- a/posthog/clickhouse/query_log_archive.py+++ b/posthog/clickhouse/query_log_archive.py@@ -487,3 +487,315 @@ def QUERY_LOG_ARCHIVE_ADD_MODIFIERS_COLUMN_SQL(table=QUERY_LOG_ARCHIVE_DATA_TABLdef QUERY_LOG_ARCHIVE_UPDATE_MV_SQL(mv_name=QUERY_LOG_ARCHIVE_MV):return f"""ALTER TABLE {mv_name} MODIFY QUERY {MV_SELECT_SQL}"""+++# ============================================================================+# OPS generation+# ----------------------------------------------------------------------------+# Single physical data table living ONLY on the OPS cluster. Every cluster gets+# a Distributed read table (query_log_archive) and a Distributed write table+# (writable_query_log_archive) pointing at it, so logs from the whole fleet are+# archived into OPS and can be read from anywhere.+#+# log_comment is stored as a native ClickHouse JSON column holding a curated+# subset of system.query_log.log_comment (typed hints for the hot dimensions,+# SKIP for PII/bulky keys). ProfileEvents is stored as the raw Map. All lc_* and+# ProfileEvents_* columns are read-time ALIASes over those two columns, so the+# MV and the writable table only ever carry the real physical columns.+# ============================================================================++WRITABLE_QUERY_LOG_ARCHIVE_TABLE = "writable_query_log_archive"+QUERY_LOG_ARCHIVE_OPS_MV = "ops_query_log_archive_mv" # slim MV -> writable_query_log_archive, on every cluster++# Curated JSON subset of log_comment. Keys not hinted here are still kept as+# dynamic paths (bounded by max_dynamic_paths) UNLESS listed in SKIP. The SKIP+# list drops PII (user_email, http_*) and bulky objects (query_settings, timings,+# filter, hogql_features) so they never reach the archive. The `query` and+# `modifiers` subtrees are intentionally NOT skipped so the lc_query* / lc_modifiers+# aliases can read them back.+LOG_COMMENT_JSON_TYPE = """JSON(+ max_dynamic_paths = 256,+ team_id Int64,+ user_id Int64,+ org_id String,+ session_id String,+ access_method LowCardinality(String),+ api_key_label String,+ api_key_mask String,+ workflow LowCardinality(String),+ kind LowCardinality(String),+ id String,+ route_id String,+ query_type LowCardinality(String),+ product LowCardinality(String),+ chargeable Bool,+ name String,+ request_name String,+ client_query_id String,+ is_impersonated Bool,+ dashboard_id Int64,+ insight_id Int64,+ cohort_id Int64,+ batch_export_id String,+ experiment_id Int64,+ experiment_feature_flag_key String,+ alert_config_id String,+ feature LowCardinality(String),+ table_id String,+ warehouse_query Bool,+ person_on_events_mode LowCardinality(String),+ service_name String,+ workload LowCardinality(String),+ `temporal.workflow_namespace` String,+ `temporal.workflow_type` String,+ `temporal.workflow_id` String,+ `temporal.workflow_run_id` String,+ `temporal.activity_type` String,+ `temporal.activity_id` String,+ `temporal.attempt` Int64,+ `dagster.job_name` String,+ `dagster.run_id` String,+ `dagster.tags.owner` String,+ SKIP user_email,+ SKIP query_settings,+ SKIP timings,+ SKIP `filter`,+ SKIP hogql_features,+ SKIP http_referer,+ SKIP http_user_agent,+ SKIP http_request_id,+ SKIP cache_key+ )"""++# Real columns copied verbatim from system.query_log, plus the physical team_id+# (it is part of the sort key so it cannot be an alias), the JSON log_comment and+# the raw ProfileEvents map. These are exactly the columns the MV inserts.+_QUERY_LOG_ARCHIVE_PHYSICAL_COLUMNS = """+ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart' = 1, 'QueryFinish' = 2, 'ExceptionBeforeStart' = 3, 'ExceptionWhileProcessing' = 4),++ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,++ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,++ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),++ exception_code Int32,+ exception String,+ stack_trace String,++ team_id Int64,+ log_comment {log_comment_type},+ ProfileEvents Map(String, UInt64)""".format(log_comment_type=LOG_COMMENT_JSON_TYPE)++# 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+# gating) against the serialized JSON.+_QUERY_LOG_ARCHIVE_ALIAS_COLUMNS = """+ exception_name String ALIAS errorCodeToName(exception_code),++ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],++ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS log_comment.id::String,+ lc_route_id String ALIAS log_comment.route_id::String,+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS log_comment.api_key_label::String,+ lc_api_key_mask String ALIAS log_comment.api_key_mask::String,+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS log_comment.name::String,+ lc_request_name String ALIAS log_comment.request_name::String,+ lc_client_query_id String ALIAS log_comment.client_query_id::String,+ lc_org_id String ALIAS log_comment.org_id::String,+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS log_comment.session_id::String,+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS log_comment.batch_export_id::String,+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS log_comment.experiment_feature_flag_key::String,+ lc_alert_config_id String ALIAS log_comment.alert_config_id::String,+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS log_comment.table_id::String,+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS log_comment.service_name::String,+ lc_workload LowCardinality(String) ALIAS log_comment.workload,++ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'),+ JSONExtractString(toString(log_comment), 'query', 'source', 'kind'),+ JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(not is_initial_query, '',+ JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'),+ JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),++ lc_temporal__workflow_namespace String ALIAS log_comment.`temporal.workflow_namespace`::String,+ lc_temporal__workflow_type String ALIAS log_comment.`temporal.workflow_type`::String,+ lc_temporal__workflow_id String ALIAS log_comment.`temporal.workflow_id`::String,+ lc_temporal__workflow_run_id String ALIAS log_comment.`temporal.workflow_run_id`::String,+ lc_temporal__activity_type String ALIAS log_comment.`temporal.activity_type`::String,+ lc_temporal__activity_id String ALIAS log_comment.`temporal.activity_id`::String,+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,++ lc_dagster__job_name String ALIAS log_comment.`dagster.job_name`::String,+ 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'), '')"""++_QUERY_LOG_ARCHIVE_OPS_TABLE_CLAUSES = """+PARTITION BY toYYYYMM(event_date)+ORDER BY (team_id, event_date, event_time, query_id)+PRIMARY KEY (team_id, event_date, event_time, query_id)"""+++def QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(table_name, engine, include_aliases=True, include_table_clauses=True):+ """JSON-backed query_log_archive table.++ include_aliases=True for the data table and read tables (exposes lc_* / ProfileEvents_*).+ include_aliases=False for the writable distributed table (physical, insertable columns only).+ """+ columns = _QUERY_LOG_ARCHIVE_PHYSICAL_COLUMNS+ if include_aliases:+ columns = f"{columns},\n{_QUERY_LOG_ARCHIVE_ALIAS_COLUMNS}"+ return "CREATE TABLE IF NOT EXISTS {table_name} (\n{columns}\n) ENGINE = {engine}{table_clauses}".format(+ table_name=table_name,+ columns=columns,+ engine=engine,+ table_clauses=_QUERY_LOG_ARCHIVE_OPS_TABLE_CLAUSES if include_table_clauses else "",+ )+++def SHARDED_QUERY_LOG_ARCHIVE_OPS_ENGINE():+ # OPS is a single-shard (1xN) cluster: replicated, not sharded.+ return MergeTreeEngine(SHARDED_QUERY_LOG_ARCHIVE_TABLE, replication_scheme=ReplicationScheme.REPLICATED)+++def SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL():+ return QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(+ table_name=SHARDED_QUERY_LOG_ARCHIVE_TABLE,+ engine=SHARDED_QUERY_LOG_ARCHIVE_OPS_ENGINE(),+ )+++def DISTRIBUTED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(cluster=None):+ """Distributed read table (query_log_archive), created on every cluster, pointing at OPS."""+ return QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(+ table_name=QUERY_LOG_ARCHIVE_DATA_TABLE,+ engine=Distributed(+ data_table=SHARDED_QUERY_LOG_ARCHIVE_TABLE,+ cluster=cluster or settings.CLICKHOUSE_OPS_CLUSTER,+ ),+ include_table_clauses=False,+ )+++def WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(cluster=None):+ """Distributed write table carrying physical columns only, pointing at OPS."""+ return QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(+ table_name=WRITABLE_QUERY_LOG_ARCHIVE_TABLE,+ engine=Distributed(+ data_table=SHARDED_QUERY_LOG_ARCHIVE_TABLE,+ cluster=cluster or settings.CLICKHOUSE_OPS_CLUSTER,+ ),+ include_aliases=False,+ include_table_clauses=False,+ )+++# The MV stays trivial: real columns pass through, team_id is extracted as a concrete+# value (sort key), and the raw log_comment String is cast into the JSON column on insert+# (the column's type hints + SKIP rules do the curation). ProfileEvents is copied as-is.+MV_SELECT_SQL_OPS = """+SELECT+ hostname,+ user,+ query_id,+ initial_query_id,+ is_initial_query,+ type,++ event_date,+ event_time,+ event_time_microseconds,+ query_start_time,+ query_start_time_microseconds,+ query_duration_ms,++ read_rows,+ read_bytes,+ written_rows,+ written_bytes,+ result_rows,+ result_bytes,+ memory_usage,+ peak_threads_usage,++ current_database,+ query,+ formatted_query,+ normalized_query_hash,+ query_kind,++ exception_code,+ exception,+ stack_trace,++ JSONExtractInt(log_comment, 'team_id') as team_id,+ log_comment,+ ProfileEvents+FROM system.query_log+WHERE+ type != 'QueryStart'+"""+++def QUERY_LOG_ARCHIVE_OPS_MV_SQL(view_name, dest_table):+ return "CREATE MATERIALIZED VIEW IF NOT EXISTS {view_name}\nTO {dest_table}\nAS {select_sql}".format(+ view_name=view_name,+ dest_table=dest_table,+ select_sql=MV_SELECT_SQL_OPS,+ )diff --git a/posthog/clickhouse/schema.py b/posthog/clickhouse/schema.pyindex f1ecea64899a..05f5c76e858a 100644--- a/posthog/clickhouse/schema.py+++ b/posthog/clickhouse/schema.py@@ -84,11 +84,12 @@ from posthog.clickhouse.property_values import (PROPERTY_VALUES_TABLE_SQL,)from posthog.clickhouse.query_log_archive import (- QUERY_LOG_ARCHIVE_DATA_TABLE,- QUERY_LOG_ARCHIVE_MV,- QUERY_LOG_ARCHIVE_NEW_MV_SQL,- QUERY_LOG_ARCHIVE_NEW_TABLE_SQL,- QUERY_LOG_ARCHIVE_TABLE_ENGINE_NEW,+ DISTRIBUTED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ QUERY_LOG_ARCHIVE_OPS_MV,+ QUERY_LOG_ARCHIVE_OPS_MV_SQL,+ SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ WRITABLE_QUERY_LOG_ARCHIVE_TABLE,)from posthog.heatmaps.sql import (DISTRIBUTED_HEATMAPS_TABLE_SQL,@@ -322,9 +323,7 @@ CREATE_MERGETREE_TABLE_QUERIES = (DOCUMENT_EMBEDDINGS_BUFFER_SHARDED_TABLE_SQL,WEB_STATS_SQL,WEB_BOUNCES_SQL,- lambda: QUERY_LOG_ARCHIVE_NEW_TABLE_SQL(- table_name=QUERY_LOG_ARCHIVE_DATA_TABLE, engine=QUERY_LOG_ARCHIVE_TABLE_ENGINE_NEW()- ),+ SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,COHORT_MEMBERSHIP_TABLE_SQL,PRECALCULATED_EVENTS_SHARDED_TABLE_SQL,SHARDED_PREAGGREGATION_RESULTS_TABLE_SQL,@@ -373,6 +372,8 @@ CREATE_DISTRIBUTED_TABLE_QUERIES = (DISTRIBUTED_RAW_SESSIONS_TABLE_SQL_V3,WRITABLE_HEATMAPS_TABLE_SQL,DISTRIBUTED_HEATMAPS_TABLE_SQL,+ DISTRIBUTED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,DISTRIBUTED_SYSTEM_PROCESSES_TABLE_SQL,COHORT_MEMBERSHIP_WRITABLE_TABLE_SQL,PRECALCULATED_EVENTS_WRITABLE_TABLE_SQL,@@ -473,7 +474,7 @@ CREATE_MV_TABLE_QUERIES = (RAW_SESSIONS_TABLE_MV_SQL_V3,RAW_SESSIONS_TABLE_MV_RECORDINGS_SQL_V3,HEATMAPS_TABLE_MV_SQL,- QUERY_LOG_ARCHIVE_NEW_MV_SQL(view_name=QUERY_LOG_ARCHIVE_MV, dest_table=QUERY_LOG_ARCHIVE_DATA_TABLE),+ QUERY_LOG_ARCHIVE_OPS_MV_SQL(view_name=QUERY_LOG_ARCHIVE_OPS_MV, dest_table=WRITABLE_QUERY_LOG_ARCHIVE_TABLE),COHORT_MEMBERSHIP_MV_SQL,PRECALCULATED_EVENTS_MV_SQL,KAFKA_TO_BUFFER_MV_SQL,diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambrindex a4add77c2f57..3ad2966ff349 100644--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr@@ -3111,6 +3111,54 @@'''# ---+# name: test_create_table_query[ops_query_log_archive_mv]+ '''+ CREATE MATERIALIZED VIEW IF NOT EXISTS ops_query_log_archive_mv+ TO writable_query_log_archive+ AS+ SELECT+ hostname,+ user,+ query_id,+ initial_query_id,+ is_initial_query,+ type,++ event_date,+ event_time,+ event_time_microseconds,+ query_start_time,+ query_start_time_microseconds,+ query_duration_ms,++ read_rows,+ read_bytes,+ written_rows,+ written_bytes,+ result_rows,+ result_bytes,+ memory_usage,+ peak_threads_usage,++ current_database,+ query,+ formatted_query,+ normalized_query_hash,+ query_kind,++ exception_code,+ exception,+ stack_trace,++ JSONExtractInt(log_comment, 'team_id') as team_id,+ log_comment,+ ProfileEvents+ FROM system.query_log+ WHERE+ type != 'QueryStart'++ '''+# ---# name: test_create_table_query[partitioned_sharded_posthog_document_embeddings]'''@@ -3783,8 +3831,8 @@# ---# name: test_create_table_query[query_log_archive]'''-CREATE TABLE IF NOT EXISTS query_log_archive (+hostname LowCardinality(String),user LowCardinality(String),query_id String,@@ -3815,216 +3863,138 @@query_kind LowCardinality(String),exception_code Int32,- exception_name String ALIAS errorCodeToName(exception_code),exception String,stack_trace String,- ProfileEvents_RealTimeMicroseconds Int64,- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64,-- ProfileEvents_S3Clients Int64,- ProfileEvents_S3DeleteObjects Int64,- ProfileEvents_S3CopyObject Int64,- ProfileEvents_S3ListObjects Int64,- ProfileEvents_S3HeadObject Int64,- ProfileEvents_S3GetObjectAttributes Int64,- ProfileEvents_S3CreateMultipartUpload Int64,- ProfileEvents_S3UploadPartCopy Int64,- ProfileEvents_S3UploadPart Int64,- ProfileEvents_S3AbortMultipartUpload Int64,- ProfileEvents_S3CompleteMultipartUpload Int64,- ProfileEvents_S3PutObject Int64,- ProfileEvents_S3GetObject Int64,- ProfileEvents_ReadBufferFromS3Bytes Int64,- ProfileEvents_WriteBufferFromS3Bytes Int64,-- ProfileEvents Map(String, UInt64),-- lc_workflow LowCardinality(String),- lc_kind LowCardinality(String),- lc_id String,- lc_route_id String,-- lc_access_method LowCardinality(String),- lc_api_key_label String,- lc_api_key_mask String,-- lc_query_type LowCardinality(String),- lc_product LowCardinality(String),- lc_chargeable Bool,- lc_name String,- lc_request_name String,- lc_client_query_id String,-- lc_org_id String,- team_id Int64, -- renamed from lc_team_id, no longer an alias- lc_user_id Int64,- lc_is_impersonated Bool,- lc_session_id String,-- lc_dashboard_id Int64,- lc_insight_id Int64,- lc_cohort_id Int64,- lc_batch_export_id String,- lc_experiment_id Int64,- lc_experiment_feature_flag_key String,-- lc_alert_config_id String,- lc_feature LowCardinality(String),- lc_table_id String,- lc_warehouse_query Bool,- lc_person_on_events_mode LowCardinality(String),- lc_service_name String,- lc_workload LowCardinality(String),-- lc_query__kind LowCardinality(String),- lc_query__query String,- lc_query String,-- lc_temporal__workflow_namespace String,- lc_temporal__workflow_type String,- lc_temporal__workflow_id String,- lc_temporal__workflow_run_id String,- lc_temporal__activity_type String,- lc_temporal__activity_id String,- lc_temporal__attempt Int64,-- lc_dagster__job_name String,- lc_dagster__run_id String,- lc_dagster__owner String,-- lc_modifiers String- ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.query_log_archive_new', '{replica}-{shard}')- PARTITION BY toYYYYMM(event_date)- ORDER BY (team_id, event_date, event_time, query_id)- PRIMARY KEY (team_id, event_date, event_time, query_id)-- '''-# ----# name: test_create_table_query[query_log_archive_mv]- '''- CREATE MATERIALIZED VIEW IF NOT EXISTS query_log_archive_mv- TO query_log_archive- AS- SELECT- hostname,- user,- query_id,- initial_query_id,- is_initial_query,- type,-- event_date,- event_time,- event_time_microseconds,- query_start_time,- query_start_time_microseconds,- query_duration_ms,-- read_rows,- read_bytes,- written_rows,- written_bytes,- result_rows,- result_bytes,- memory_usage,- peak_threads_usage,-- current_database,- query,- formatted_query,- normalized_query_hash,- query_kind,-- exception_code,- exception,- stack_trace,-- ProfileEvents['RealTimeMicroseconds'] as ProfileEvents_RealTimeMicroseconds,- ProfileEvents['OSCPUVirtualTimeMicroseconds'] as ProfileEvents_OSCPUVirtualTimeMicroseconds,-- ProfileEvents['S3Clients'] as ProfileEvents_S3Clients,- ProfileEvents['S3DeleteObjects'] as ProfileEvents_S3DeleteObjects,- ProfileEvents['S3CopyObject'] as ProfileEvents_S3CopyObject,- ProfileEvents['S3ListObjects'] as ProfileEvents_S3ListObjects,- ProfileEvents['S3HeadObject'] as ProfileEvents_S3HeadObject,- ProfileEvents['S3GetObjectAttributes'] as ProfileEvents_S3GetObjectAttributes,- ProfileEvents['S3CreateMultipartUpload'] as ProfileEvents_S3CreateMultipartUpload,- ProfileEvents['S3UploadPartCopy'] as ProfileEvents_S3UploadPartCopy,- ProfileEvents['S3UploadPart'] as ProfileEvents_S3UploadPart,- ProfileEvents['S3AbortMultipartUpload'] as ProfileEvents_S3AbortMultipartUpload,- ProfileEvents['S3CompleteMultipartUpload'] as ProfileEvents_S3CompleteMultipartUpload,- ProfileEvents['S3PutObject'] as ProfileEvents_S3PutObject,- ProfileEvents['S3GetObject'] as ProfileEvents_S3GetObject,- ProfileEvents['ReadBufferFromS3Bytes'] as ProfileEvents_ReadBufferFromS3Bytes,- ProfileEvents['WriteBufferFromS3Bytes'] as ProfileEvents_WriteBufferFromS3Bytes,-- ProfileEvents,-- JSONExtractString(log_comment, 'workflow') as lc_workflow,- JSONExtractString(log_comment, 'kind') as lc_kind,- JSONExtractString(log_comment, 'id') as lc_id,- JSONExtractString(log_comment, 'route_id') as lc_route_id,-- JSONExtractString(log_comment, 'access_method') as lc_access_method,- JSONExtractString(log_comment, 'api_key_label') as lc_api_key_label,- JSONExtractString(log_comment, 'api_key_mask') as lc_api_key_mask,-- JSONExtractString(log_comment, 'query_type') as lc_query_type,- JSONExtractString(log_comment, 'product') as lc_product,- JSONExtractInt(log_comment, 'chargeable') == 1 as lc_chargeable,- JSONExtractString(log_comment, 'name') as lc_name,- JSONExtractString(log_comment, 'request_name') as lc_request_name,- JSONExtractString(log_comment, 'client_query_id') as lc_client_query_id,-- JSONExtractString(log_comment, 'org_id') as lc_org_id,- JSONExtractInt(log_comment, 'team_id') as team_id,- JSONExtractInt(log_comment, 'user_id') as lc_user_id,- JSONExtractBool(log_comment, 'is_impersonated') as lc_is_impersonated,- JSONExtractString(log_comment, 'session_id') as lc_session_id,-- JSONExtractInt(log_comment, 'dashboard_id') as lc_dashboard_id,- JSONExtractInt(log_comment, 'insight_id') as lc_insight_id,- JSONExtractInt(log_comment, 'cohort_id') as lc_cohort_id,- JSONExtractString(log_comment, 'batch_export_id') as lc_batch_export_id,- JSONExtractInt(log_comment, 'experiment_id') as lc_experiment_id,- JSONExtractString(log_comment, 'experiment_feature_flag_key') as lc_experiment_feature_flag_key,-- JSONExtractString(log_comment, 'alert_config_id') as lc_alert_config_id,- JSONExtractString(log_comment, 'feature') as lc_feature,- JSONExtractString(log_comment, 'table_id') as lc_table_id,- JSONExtractInt(log_comment, 'warehouse_query') == 1 as lc_warehouse_query,- JSONExtractString(log_comment, 'person_on_events_mode') as lc_person_on_events_mode,- JSONExtractString(log_comment, 'service_name') as lc_service_name,- JSONExtractString(log_comment, 'workload') as lc_workload,-- -- for entries with 'query' tag, some queries have source, we should use this- if(JSONHas(log_comment, 'query', 'source'),- JSONExtractString(log_comment, 'query', 'source', 'kind'),- JSONExtractString(log_comment, 'query', 'kind')) as lc_query__kind,- multiIf(not is_initial_query, '',- JSONHas(log_comment, 'query', 'source'), JSONExtractString(log_comment, 'query', 'source', 'query'),- JSONExtractString(log_comment, 'query', 'query')) as lc_query__query,- if(is_initial_query, JSONExtractRaw(log_comment, 'query'), '') as lc_query,-- JSONExtractString(log_comment, 'temporal', 'workflow_namespace') as lc_temporal__workflow_namespace,- JSONExtractString(log_comment, 'temporal', 'workflow_type') as lc_temporal__workflow_type,- JSONExtractString(log_comment, 'temporal', 'workflow_id') as lc_temporal__workflow_id,- JSONExtractString(log_comment, 'temporal', 'workflow_run_id') as lc_temporal__workflow_run_id,- JSONExtractString(log_comment, 'temporal', 'activity_type') as lc_temporal__activity_type,- JSONExtractString(log_comment, 'temporal', 'activity_id') as lc_temporal__activity_id,- JSONExtractInt(log_comment, 'temporal', 'attempt') as lc_temporal__attempt,-- JSONExtractString(log_comment, 'dagster', 'job_name') as lc_dagster__job_name,- JSONExtractString(log_comment, 'dagster', 'run_id') as lc_dagster__run_id,- JSONExtractString(log_comment, 'dagster', 'tags', 'owner') as lc_dagster__owner,-- if(is_initial_query, JSONExtractRaw(log_comment, 'modifiers'), '') as lc_modifiers- FROM system.query_log- WHERE- type != 'QueryStart'--+ team_id Int64,+ log_comment JSON(+ max_dynamic_paths = 256,+ team_id Int64,+ user_id Int64,+ org_id String,+ session_id String,+ access_method LowCardinality(String),+ api_key_label String,+ api_key_mask String,+ workflow LowCardinality(String),+ kind LowCardinality(String),+ id String,+ route_id String,+ query_type LowCardinality(String),+ product LowCardinality(String),+ chargeable Bool,+ name String,+ request_name String,+ client_query_id String,+ is_impersonated Bool,+ dashboard_id Int64,+ insight_id Int64,+ cohort_id Int64,+ batch_export_id String,+ experiment_id Int64,+ experiment_feature_flag_key String,+ alert_config_id String,+ feature LowCardinality(String),+ table_id String,+ warehouse_query Bool,+ person_on_events_mode LowCardinality(String),+ service_name String,+ workload LowCardinality(String),+ `temporal.workflow_namespace` String,+ `temporal.workflow_type` String,+ `temporal.workflow_id` String,+ `temporal.workflow_run_id` String,+ `temporal.activity_type` String,+ `temporal.activity_id` String,+ `temporal.attempt` Int64,+ `dagster.job_name` String,+ `dagster.run_id` String,+ `dagster.tags.owner` String,+ SKIP user_email,+ SKIP query_settings,+ SKIP timings,+ SKIP `filter`,+ SKIP hogql_features,+ SKIP http_referer,+ SKIP http_user_agent,+ SKIP http_request_id,+ SKIP cache_key+ ),+ ProfileEvents Map(String, UInt64),++ exception_name String ALIAS errorCodeToName(exception_code),++ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],++ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS log_comment.id::String,+ lc_route_id String ALIAS log_comment.route_id::String,+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS log_comment.api_key_label::String,+ lc_api_key_mask String ALIAS log_comment.api_key_mask::String,+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS log_comment.name::String,+ lc_request_name String ALIAS log_comment.request_name::String,+ lc_client_query_id String ALIAS log_comment.client_query_id::String,+ lc_org_id String ALIAS log_comment.org_id::String,+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS log_comment.session_id::String,+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS log_comment.batch_export_id::String,+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS log_comment.experiment_feature_flag_key::String,+ lc_alert_config_id String ALIAS log_comment.alert_config_id::String,+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS log_comment.table_id::String,+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS log_comment.service_name::String,+ lc_workload LowCardinality(String) ALIAS log_comment.workload,++ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'),+ JSONExtractString(toString(log_comment), 'query', 'source', 'kind'),+ JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(not is_initial_query, '',+ JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'),+ JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),++ lc_temporal__workflow_namespace String ALIAS log_comment.`temporal.workflow_namespace`::String,+ lc_temporal__workflow_type String ALIAS log_comment.`temporal.workflow_type`::String,+ lc_temporal__workflow_id String ALIAS log_comment.`temporal.workflow_id`::String,+ lc_temporal__workflow_run_id String ALIAS log_comment.`temporal.workflow_run_id`::String,+ lc_temporal__activity_type String ALIAS log_comment.`temporal.activity_type`::String,+ lc_temporal__activity_id String ALIAS log_comment.`temporal.activity_id`::String,+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,++ lc_dagster__job_name String ALIAS log_comment.`dagster.job_name`::String,+ 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'), '')+ ) ENGINE = Distributed('ops', 'posthog_test', 'sharded_query_log_archive')'''# ---# name: test_create_table_query[raw_error_tracking_fingerprint_issue_state]@@ -5797,6 +5767,177 @@'''# ---+# name: test_create_table_query[sharded_query_log_archive]+ '''+ CREATE TABLE IF NOT EXISTS sharded_query_log_archive (++ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart' = 1, 'QueryFinish' = 2, 'ExceptionBeforeStart' = 3, 'ExceptionWhileProcessing' = 4),++ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,++ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,++ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),++ exception_code Int32,+ exception String,+ stack_trace String,++ team_id Int64,+ log_comment JSON(+ max_dynamic_paths = 256,+ team_id Int64,+ user_id Int64,+ org_id String,+ session_id String,+ access_method LowCardinality(String),+ api_key_label String,+ api_key_mask String,+ workflow LowCardinality(String),+ kind LowCardinality(String),+ id String,+ route_id String,+ query_type LowCardinality(String),+ product LowCardinality(String),+ chargeable Bool,+ name String,+ request_name String,+ client_query_id String,+ is_impersonated Bool,+ dashboard_id Int64,+ insight_id Int64,+ cohort_id Int64,+ batch_export_id String,+ experiment_id Int64,+ experiment_feature_flag_key String,+ alert_config_id String,+ feature LowCardinality(String),+ table_id String,+ warehouse_query Bool,+ person_on_events_mode LowCardinality(String),+ service_name String,+ workload LowCardinality(String),+ `temporal.workflow_namespace` String,+ `temporal.workflow_type` String,+ `temporal.workflow_id` String,+ `temporal.workflow_run_id` String,+ `temporal.activity_type` String,+ `temporal.activity_id` String,+ `temporal.attempt` Int64,+ `dagster.job_name` String,+ `dagster.run_id` String,+ `dagster.tags.owner` String,+ SKIP user_email,+ SKIP query_settings,+ SKIP timings,+ SKIP `filter`,+ SKIP hogql_features,+ SKIP http_referer,+ SKIP http_user_agent,+ SKIP http_request_id,+ SKIP cache_key+ ),+ ProfileEvents Map(String, UInt64),++ exception_name String ALIAS errorCodeToName(exception_code),++ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],++ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS log_comment.id::String,+ lc_route_id String ALIAS log_comment.route_id::String,+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS log_comment.api_key_label::String,+ lc_api_key_mask String ALIAS log_comment.api_key_mask::String,+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS log_comment.name::String,+ lc_request_name String ALIAS log_comment.request_name::String,+ lc_client_query_id String ALIAS log_comment.client_query_id::String,+ lc_org_id String ALIAS log_comment.org_id::String,+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS log_comment.session_id::String,+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS log_comment.batch_export_id::String,+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS log_comment.experiment_feature_flag_key::String,+ lc_alert_config_id String ALIAS log_comment.alert_config_id::String,+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS log_comment.table_id::String,+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS log_comment.service_name::String,+ lc_workload LowCardinality(String) ALIAS log_comment.workload,++ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'),+ JSONExtractString(toString(log_comment), 'query', 'source', 'kind'),+ JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(not is_initial_query, '',+ JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'),+ JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),++ lc_temporal__workflow_namespace String ALIAS log_comment.`temporal.workflow_namespace`::String,+ lc_temporal__workflow_type String ALIAS log_comment.`temporal.workflow_type`::String,+ lc_temporal__workflow_id String ALIAS log_comment.`temporal.workflow_id`::String,+ lc_temporal__workflow_run_id String ALIAS log_comment.`temporal.workflow_run_id`::String,+ lc_temporal__activity_type String ALIAS log_comment.`temporal.activity_type`::String,+ lc_temporal__activity_id String ALIAS log_comment.`temporal.activity_id`::String,+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,++ lc_dagster__job_name String ALIAS log_comment.`dagster.job_name`::String,+ 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'), '')+ ) 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)+ PRIMARY KEY (team_id, event_date, event_time, query_id)+ '''+# ---# name: test_create_table_query[sharded_raw_sessions]'''@@ -7525,6 +7666,101 @@'''# ---+# name: test_create_table_query[writable_query_log_archive]+ '''+ CREATE TABLE IF NOT EXISTS writable_query_log_archive (++ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart' = 1, 'QueryFinish' = 2, 'ExceptionBeforeStart' = 3, 'ExceptionWhileProcessing' = 4),++ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,++ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,++ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),++ exception_code Int32,+ exception String,+ stack_trace String,++ team_id Int64,+ log_comment JSON(+ max_dynamic_paths = 256,+ team_id Int64,+ user_id Int64,+ org_id String,+ session_id String,+ access_method LowCardinality(String),+ api_key_label String,+ api_key_mask String,+ workflow LowCardinality(String),+ kind LowCardinality(String),+ id String,+ route_id String,+ query_type LowCardinality(String),+ product LowCardinality(String),+ chargeable Bool,+ name String,+ request_name String,+ client_query_id String,+ is_impersonated Bool,+ dashboard_id Int64,+ insight_id Int64,+ cohort_id Int64,+ batch_export_id String,+ experiment_id Int64,+ experiment_feature_flag_key String,+ alert_config_id String,+ feature LowCardinality(String),+ table_id String,+ warehouse_query Bool,+ person_on_events_mode LowCardinality(String),+ service_name String,+ workload LowCardinality(String),+ `temporal.workflow_namespace` String,+ `temporal.workflow_type` String,+ `temporal.workflow_id` String,+ `temporal.workflow_run_id` String,+ `temporal.activity_type` String,+ `temporal.activity_id` String,+ `temporal.attempt` Int64,+ `dagster.job_name` String,+ `dagster.run_id` String,+ `dagster.tags.owner` String,+ SKIP user_email,+ SKIP query_settings,+ SKIP timings,+ SKIP `filter`,+ SKIP hogql_features,+ SKIP http_referer,+ SKIP http_user_agent,+ SKIP http_request_id,+ SKIP cache_key+ ),+ ProfileEvents Map(String, UInt64)+ ) ENGINE = Distributed('ops', 'posthog_test', 'sharded_query_log_archive')+ '''+# ---# name: test_create_table_query[writable_raw_sessions]'''@@ -8766,126 +9002,6 @@'''# ----# name: test_create_table_query_replicated_and_storage[query_log_archive]- '''-- CREATE TABLE IF NOT EXISTS query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart' = 1, 'QueryFinish' = 2, 'ExceptionBeforeStart' = 3, 'ExceptionWhileProcessing' = 4),-- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,-- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,-- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),-- exception_code Int32,- exception_name String ALIAS errorCodeToName(exception_code),- exception String,- stack_trace String,-- ProfileEvents_RealTimeMicroseconds Int64,- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64,-- ProfileEvents_S3Clients Int64,- ProfileEvents_S3DeleteObjects Int64,- ProfileEvents_S3CopyObject Int64,- ProfileEvents_S3ListObjects Int64,- ProfileEvents_S3HeadObject Int64,- ProfileEvents_S3GetObjectAttributes Int64,- ProfileEvents_S3CreateMultipartUpload Int64,- ProfileEvents_S3UploadPartCopy Int64,- ProfileEvents_S3UploadPart Int64,- ProfileEvents_S3AbortMultipartUpload Int64,- ProfileEvents_S3CompleteMultipartUpload Int64,- ProfileEvents_S3PutObject Int64,- ProfileEvents_S3GetObject Int64,- ProfileEvents_ReadBufferFromS3Bytes Int64,- ProfileEvents_WriteBufferFromS3Bytes Int64,-- ProfileEvents Map(String, UInt64),-- lc_workflow LowCardinality(String),- lc_kind LowCardinality(String),- lc_id String,- lc_route_id String,-- lc_access_method LowCardinality(String),- lc_api_key_label String,- lc_api_key_mask String,-- lc_query_type LowCardinality(String),- lc_product LowCardinality(String),- lc_chargeable Bool,- lc_name String,- lc_request_name String,- lc_client_query_id String,-- lc_org_id String,- team_id Int64, -- renamed from lc_team_id, no longer an alias- lc_user_id Int64,- lc_is_impersonated Bool,- lc_session_id String,-- lc_dashboard_id Int64,- lc_insight_id Int64,- lc_cohort_id Int64,- lc_batch_export_id String,- lc_experiment_id Int64,- lc_experiment_feature_flag_key String,-- lc_alert_config_id String,- lc_feature LowCardinality(String),- lc_table_id String,- lc_warehouse_query Bool,- lc_person_on_events_mode LowCardinality(String),- lc_service_name String,- lc_workload LowCardinality(String),-- lc_query__kind LowCardinality(String),- lc_query__query String,- lc_query String,-- lc_temporal__workflow_namespace String,- lc_temporal__workflow_type String,- lc_temporal__workflow_id String,- lc_temporal__workflow_run_id String,- lc_temporal__activity_type String,- lc_temporal__activity_id String,- lc_temporal__attempt Int64,-- lc_dagster__job_name String,- lc_dagster__run_id String,- lc_dagster__owner String,-- lc_modifiers String- ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.query_log_archive_new', '{replica}-{shard}')- PARTITION BY toYYYYMM(event_date)- ORDER BY (team_id, event_date, event_time, query_id)- PRIMARY KEY (team_id, event_date, event_time, query_id)-- '''-# ---# name: test_create_table_query_replicated_and_storage[raw_error_tracking_fingerprint_issue_state]'''@@ -9653,6 +9769,177 @@'''# ---+# name: test_create_table_query_replicated_and_storage[sharded_query_log_archive]+ '''+ CREATE TABLE IF NOT EXISTS sharded_query_log_archive (++ hostname LowCardinality(String),+ user LowCardinality(String),+ query_id String,+ initial_query_id String,+ is_initial_query UInt8,+ type Enum8('QueryStart' = 1, 'QueryFinish' = 2, 'ExceptionBeforeStart' = 3, 'ExceptionWhileProcessing' = 4),++ event_date Date,+ event_time DateTime,+ event_time_microseconds DateTime64(6),+ query_start_time DateTime,+ query_start_time_microseconds DateTime64(6),+ query_duration_ms UInt64,++ read_rows UInt64,+ read_bytes UInt64,+ written_rows UInt64,+ written_bytes UInt64,+ result_rows UInt64,+ result_bytes UInt64,+ memory_usage UInt64,+ peak_threads_usage UInt64,++ current_database LowCardinality(String),+ query String,+ formatted_query String,+ normalized_query_hash UInt64,+ query_kind LowCardinality(String),++ exception_code Int32,+ exception String,+ stack_trace String,++ team_id Int64,+ log_comment JSON(+ max_dynamic_paths = 256,+ team_id Int64,+ user_id Int64,+ org_id String,+ session_id String,+ access_method LowCardinality(String),+ api_key_label String,+ api_key_mask String,+ workflow LowCardinality(String),+ kind LowCardinality(String),+ id String,+ route_id String,+ query_type LowCardinality(String),+ product LowCardinality(String),+ chargeable Bool,+ name String,+ request_name String,+ client_query_id String,+ is_impersonated Bool,+ dashboard_id Int64,+ insight_id Int64,+ cohort_id Int64,+ batch_export_id String,+ experiment_id Int64,+ experiment_feature_flag_key String,+ alert_config_id String,+ feature LowCardinality(String),+ table_id String,+ warehouse_query Bool,+ person_on_events_mode LowCardinality(String),+ service_name String,+ workload LowCardinality(String),+ `temporal.workflow_namespace` String,+ `temporal.workflow_type` String,+ `temporal.workflow_id` String,+ `temporal.workflow_run_id` String,+ `temporal.activity_type` String,+ `temporal.activity_id` String,+ `temporal.attempt` Int64,+ `dagster.job_name` String,+ `dagster.run_id` String,+ `dagster.tags.owner` String,+ SKIP user_email,+ SKIP query_settings,+ SKIP timings,+ SKIP `filter`,+ SKIP hogql_features,+ SKIP http_referer,+ SKIP http_user_agent,+ SKIP http_request_id,+ SKIP cache_key+ ),+ ProfileEvents Map(String, UInt64),++ exception_name String ALIAS errorCodeToName(exception_code),++ ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],+ ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],+ ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],+ ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],+ ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],+ ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],+ ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],+ ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],+ ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],+ ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],+ ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],+ ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],+ ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],+ ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],+ ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],+ ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],+ ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],++ lc_workflow LowCardinality(String) ALIAS log_comment.workflow,+ lc_kind LowCardinality(String) ALIAS log_comment.kind,+ lc_id String ALIAS log_comment.id::String,+ lc_route_id String ALIAS log_comment.route_id::String,+ lc_access_method LowCardinality(String) ALIAS log_comment.access_method,+ lc_api_key_label String ALIAS log_comment.api_key_label::String,+ lc_api_key_mask String ALIAS log_comment.api_key_mask::String,+ lc_query_type LowCardinality(String) ALIAS log_comment.query_type,+ lc_product LowCardinality(String) ALIAS log_comment.product,+ lc_chargeable Bool ALIAS log_comment.chargeable,+ lc_name String ALIAS log_comment.name::String,+ lc_request_name String ALIAS log_comment.request_name::String,+ lc_client_query_id String ALIAS log_comment.client_query_id::String,+ lc_org_id String ALIAS log_comment.org_id::String,+ lc_user_id Int64 ALIAS log_comment.user_id,+ lc_is_impersonated Bool ALIAS log_comment.is_impersonated,+ lc_session_id String ALIAS log_comment.session_id::String,+ lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,+ lc_insight_id Int64 ALIAS log_comment.insight_id,+ lc_cohort_id Int64 ALIAS log_comment.cohort_id,+ lc_batch_export_id String ALIAS log_comment.batch_export_id::String,+ lc_experiment_id Int64 ALIAS log_comment.experiment_id,+ lc_experiment_feature_flag_key String ALIAS log_comment.experiment_feature_flag_key::String,+ lc_alert_config_id String ALIAS log_comment.alert_config_id::String,+ lc_feature LowCardinality(String) ALIAS log_comment.feature,+ lc_table_id String ALIAS log_comment.table_id::String,+ lc_warehouse_query Bool ALIAS log_comment.warehouse_query,+ lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,+ lc_service_name String ALIAS log_comment.service_name::String,+ lc_workload LowCardinality(String) ALIAS log_comment.workload,++ lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'),+ JSONExtractString(toString(log_comment), 'query', 'source', 'kind'),+ JSONExtractString(toString(log_comment), 'query', 'kind')),+ lc_query__query String ALIAS multiIf(not is_initial_query, '',+ JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'),+ JSONExtractString(toString(log_comment), 'query', 'query')),+ lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),++ lc_temporal__workflow_namespace String ALIAS log_comment.`temporal.workflow_namespace`::String,+ lc_temporal__workflow_type String ALIAS log_comment.`temporal.workflow_type`::String,+ lc_temporal__workflow_id String ALIAS log_comment.`temporal.workflow_id`::String,+ lc_temporal__workflow_run_id String ALIAS log_comment.`temporal.workflow_run_id`::String,+ lc_temporal__activity_type String ALIAS log_comment.`temporal.activity_type`::String,+ lc_temporal__activity_id String ALIAS log_comment.`temporal.activity_id`::String,+ lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,++ lc_dagster__job_name String ALIAS log_comment.`dagster.job_name`::String,+ 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'), '')+ ) 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)+ PRIMARY KEY (team_id, event_date, event_time, query_id)+ '''+# ---# name: test_create_table_query_replicated_and_storage[sharded_raw_sessions]'''diff --git a/posthog/settings/data_stores.py b/posthog/settings/data_stores.pyindex fa50975bda6b..020133e5bf96 100644--- a/posthog/settings/data_stores.py+++ b/posthog/settings/data_stores.py@@ -313,6 +313,9 @@ CLICKHOUSE_WRITABLE_CLUSTER: str = os.getenv("CLICKHOUSE_WRITABLE_CLUSTER", "posCLICKHOUSE_PRIMARY_REPLICA_CLUSTER: str = os.getenv("CLICKHOUSE_PRIMARY_REPLICA_CLUSTER", "posthog_primary_replica")CLICKHOUSE_AUX_CLUSTER: str = os.getenv("CLICKHOUSE_AUX_CLUSTER", "aux")CLICKHOUSE_AI_EVENTS_CLUSTER: str = os.getenv("CLICKHOUSE_AI_EVENTS_CLUSTER", "ai_events")+# query_log_archive's single data table lives on the OPS cluster; every cluster's+# Distributed read/write tables route to it via this cluster name.+CLICKHOUSE_OPS_CLUSTER: str = os.getenv("CLICKHOUSE_OPS_CLUSTER", "ops")# Opt-in flag for the multinode ClickHouse smoke-test stack. When true, migrations# respect their declared NodeRole(s) instead of being collapsed to NodeRole.ALL,# so a per-cluster topology can actually exercise routing.diff --git a/posthog/test/base.py b/posthog/test/base.pyindex 5e50bf5a8eee..fb00f952fd17 100644--- a/posthog/test/base.py+++ b/posthog/test/base.py@@ -67,11 +67,12 @@ from posthog.clickhouse.preaggregation.sql import (SHARDED_PREAGGREGATION_RESULTS_TABLE_SQL,)from posthog.clickhouse.query_log_archive import (- QUERY_LOG_ARCHIVE_DATA_TABLE,- QUERY_LOG_ARCHIVE_MV,- QUERY_LOG_ARCHIVE_NEW_MV_SQL,- QUERY_LOG_ARCHIVE_NEW_TABLE_SQL,- QUERY_LOG_ARCHIVE_TABLE_ENGINE_NEW,+ DISTRIBUTED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ QUERY_LOG_ARCHIVE_OPS_MV,+ QUERY_LOG_ARCHIVE_OPS_MV_SQL,+ SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,+ WRITABLE_QUERY_LOG_ARCHIVE_TABLE,)from posthog.cloud_utils import TEST_clear_instance_license_cachefrom posthog.helpers.two_factor_session import email_mfa_token_generator@@ -1732,9 +1733,7 @@ def reset_clickhouse_database() -> None:WEB_STATS_SQL(table_name="web_pre_aggregated_stats_staging"),WEB_BOUNCES_SQL(table_name="web_pre_aggregated_bounces_staging"),WEB_PRE_AGGREGATED_TEAM_SELECTION_TABLE_SQL(),- QUERY_LOG_ARCHIVE_NEW_TABLE_SQL(- table_name=QUERY_LOG_ARCHIVE_DATA_TABLE, engine=QUERY_LOG_ARCHIVE_TABLE_ENGINE_NEW()- ),+ SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(),COHORT_MEMBERSHIP_TABLE_SQL(),PRECALCULATED_EVENTS_SHARDED_TABLE_SQL(),SHARDED_PREAGGREGATION_RESULTS_TABLE_SQL(),@@ -1756,7 +1755,8 @@ def reset_clickhouse_database() -> None:CUSTOM_METRICS_TEST_VIEW(),CUSTOM_METRICS_REPLICATION_QUEUE_VIEW(),WEB_PRE_AGGREGATED_TEAM_SELECTION_DICTIONARY_SQL(),- QUERY_LOG_ARCHIVE_NEW_MV_SQL(view_name=QUERY_LOG_ARCHIVE_MV, dest_table=QUERY_LOG_ARCHIVE_DATA_TABLE),+ DISTRIBUTED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(),+ WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(),COHORT_MEMBERSHIP_WRITABLE_TABLE_SQL(),KAFKA_COHORT_MEMBERSHIP_TABLE_SQL(),PRECALCULATED_EVENTS_WRITABLE_TABLE_SQL(),@@ -1779,6 +1779,9 @@ def reset_clickhouse_database() -> None:WEB_PRE_AGGREGATED_TEAM_SELECTION_DATA_SQL(),COHORT_MEMBERSHIP_MV_SQL(),PRECALCULATED_EVENTS_MV_SQL(),+ QUERY_LOG_ARCHIVE_OPS_MV_SQL(+ view_name=QUERY_LOG_ARCHIVE_OPS_MV, dest_table=WRITABLE_QUERY_LOG_ARCHIVE_TABLE+ ),])