Skip to content

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

chore(logs): list kafka_logs34_avro_mv columns explicitly (#82520)

Frank Hamand32e7c26ba79b
diff --git a/posthog/clickhouse/hcl/golden/dev/logs.hcl b/posthog/clickhouse/hcl/golden/dev/logs.hcl
index 7cde0b423ba3..0cca7c884715 100644
--- a/posthog/clickhouse/hcl/golden/dev/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/dev/logs.hcl
@@ -1737,7 +1737,18 @@ database "posthog" {
to_table = "posthog.logs34"
query = <<SQL
SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
index 79fe98ac61bd..35d72a43d2a8 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
@@ -2284,7 +2284,18 @@ SQL
to_table = "posthog.logs34"
query = <<SQL
SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
index b2bcaffbee84..f4fdd05c35ff 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
@@ -2232,7 +2232,18 @@ database "posthog" {
to_table = "posthog.logs34"
query = <<SQL
SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
index 803e2050ab66..fd9e1251c254 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
@@ -2245,7 +2245,18 @@ database "posthog" {
to_table = "posthog.logs34"
query = <<SQL
SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/roles/logs/base/sql/kafka_logs34_avro_mv.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/kafka_logs34_avro_mv.sql
index a1132b907b05..e391e9964205 100644
--- a/posthog/clickhouse/hcl/roles/logs/base/sql/kafka_logs34_avro_mv.sql
+++ b/posthog/clickhouse/hcl/roles/logs/base/sql/kafka_logs34_avro_mv.sql
@@ -1,5 +1,16 @@
SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/roles/logs/local/tables.hcl b/posthog/clickhouse/hcl/roles/logs/local/tables.hcl
index f071071d834a..69845b1a4f35 100644
--- a/posthog/clickhouse/hcl/roles/logs/local/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/local/tables.hcl
@@ -423,27 +423,6 @@ SQL
replica_name = "{replica}-{shard}"
}
}
- patch_materialized_view "kafka_logs34_avro_mv" {
- query = <<SQL
-SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),
- mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
- mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
- toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
- observed_timestamp
- + toIntervalDay(
- toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))
- ) AS original_expiry_timestamp,
- _partition,
- _topic,
- _offset,
- toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,
- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,
- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed
-FROM posthog.kafka_logs_avro
-SQL
-
- }
patch_materialized_view "kafka_logs_avro_billing_metrics_mv" {
query = <<SQL
SELECT
diff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl b/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl
index d18aef49598b..95bcc1245e69 100644
--- a/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl
@@ -30,9 +30,6 @@ database "posthog" {
thread_per_consumer = true
}
}
- patch_materialized_view "kafka_logs34_avro_mv" {
- query = file("sql/kafka_logs34_avro_mv.sql")
- }
patch_materialized_view "kafka_logs_avro_billing_metrics_mv" {
query = file("sql/kafka_logs_avro_billing_metrics_mv.sql")
}
diff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/sql/kafka_logs34_avro_mv.sql b/posthog/clickhouse/hcl/roles/logs/prod-eu/sql/kafka_logs34_avro_mv.sql
deleted file mode 100644
index 15d9fd2954f0..000000000000
--- a/posthog/clickhouse/hcl/roles/logs/prod-eu/sql/kafka_logs34_avro_mv.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),
- mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
- mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
- toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
- observed_timestamp
- + toIntervalDay(
- toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))
- ) AS original_expiry_timestamp,
- _partition,
- _topic,
- _offset,
- toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,
- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,
- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed
-FROM posthog.kafka_logs_avro
diff --git a/posthog/clickhouse/hcl/sql/dev/logs.sql b/posthog/clickhouse/hcl/sql/dev/logs.sql
index 132aa417a6c7..174017c12c41 100644
--- a/posthog/clickhouse/hcl/sql/dev/logs.sql
+++ b/posthog/clickhouse/hcl/sql/dev/logs.sql
@@ -425,7 +425,18 @@ CREATE TABLE posthog.writable_query_log_archive (
ProfileEvents Map(String, UInt64)
) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
CREATE MATERIALIZED VIEW posthog.kafka_logs34_avro_mv TO posthog.logs34 (uuid String, trace_id String, span_id String, trace_flags Int32, timestamp DateTime64(6), observed_timestamp DateTime64(6), body String, severity_text String, severity_number Int32, service_name String, instrumentation_scope String, event_name String, attributes_map_str Map(String, String), resource_attributes Map(String, String), team_id Int32, original_expiry_timestamp DateTime64(6), _partition UInt64, _topic LowCardinality(String), _offset UInt64, _record_count Int64, _bytes_uncompressed Nullable(Int64), _bytes_compressed Nullable(Int64)) AS SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/sql/local-multi/logs.sql b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
index 90b7e6d98f80..4f47a4963c3a 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/logs.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
@@ -565,7 +565,18 @@ CREATE TABLE posthog.trace_spans_kafka_metrics (
max_lag SimpleAggregateFunction(max, UInt64)
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.trace_spans_kafka_metrics', '{replica}-{shard}') ORDER BY (_topic, _partition) SETTINGS index_granularity = 8192;
CREATE MATERIALIZED VIEW posthog.kafka_logs34_avro_mv TO posthog.logs34 (uuid String, trace_id String, span_id String, trace_flags Int32, timestamp DateTime64(6), observed_timestamp DateTime64(6), body String, severity_text String, severity_number Int32, service_name String, instrumentation_scope String, event_name String, attributes_map_str Map(String, String), resource_attributes Map(String, String), team_id Int32, original_expiry_timestamp DateTime64(6), _partition UInt64, _topic LowCardinality(String), _offset UInt64, _record_count Int64, _bytes_uncompressed Nullable(Int64), _bytes_compressed Nullable(Int64)) AS SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
index a505fae2bc5f..4b077b4a03cc 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
@@ -563,7 +563,18 @@ CREATE TABLE posthog.writable_query_log_archive (
ProfileEvents Map(String, UInt64)
) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
CREATE MATERIALIZED VIEW posthog.kafka_logs34_avro_mv TO posthog.logs34 (uuid String, trace_id String, span_id String, trace_flags Int32, timestamp DateTime64(6), observed_timestamp DateTime64(6), body String, severity_text String, severity_number Int32, service_name String, instrumentation_scope String, event_name String, attributes_map_str Map(String, String), resource_attributes Map(String, String), team_id Int32, original_expiry_timestamp DateTime64(6), _partition UInt64, _topic LowCardinality(String), _offset UInt64, _record_count Int64, _bytes_uncompressed Nullable(Int64), _bytes_compressed Nullable(Int64)) AS SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/logs.sql b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
index 0a5fc76ec330..f4f40122cd75 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
@@ -565,7 +565,18 @@ CREATE TABLE posthog.writable_query_log_archive (
ProfileEvents Map(String, UInt64)
) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');
CREATE MATERIALIZED VIEW posthog.kafka_logs34_avro_mv TO posthog.logs34 (uuid String, trace_id String, span_id String, trace_flags Int32, timestamp DateTime64(6), observed_timestamp DateTime64(6), body String, severity_text String, severity_number Int32, service_name String, instrumentation_scope String, event_name String, attributes_map_str Map(String, String), resource_attributes Map(String, String), team_id Int32, original_expiry_timestamp DateTime64(6), _partition UInt64, _topic LowCardinality(String), _offset UInt64, _record_count Int64, _bytes_uncompressed Nullable(Int64), _bytes_compressed Nullable(Int64)) AS SELECT
- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes),
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
diff --git a/posthog/clickhouse/logs/__init__.py b/posthog/clickhouse/logs/__init__.py
index fa40b3d068c2..94726b0142b2 100644
--- a/posthog/clickhouse/logs/__init__.py
+++ b/posthog/clickhouse/logs/__init__.py
@@ -12,6 +12,7 @@ from .logs32 import (
)
from .logs34 import (
KAFKA_LOGS34_AVRO_MV,
+ KAFKA_LOGS34_AVRO_MV_SELECT,
KAFKA_LOGS_AVRO_BILLING_METRICS_MV,
KAFKA_LOGS_AVRO_KAFKA_METRICS_MV,
KAFKA_LOGS_AVRO_TABLE_SQL,
@@ -46,6 +47,7 @@ __all__ = [
"LOGS34_TO_RESOURCE_ATTRIBUTES3_MV",
"KAFKA_LOGS_AVRO_TABLE_SQL",
"KAFKA_LOGS34_AVRO_MV",
+ "KAFKA_LOGS34_AVRO_MV_SELECT",
"KAFKA_LOGS_AVRO_KAFKA_METRICS_MV",
"KAFKA_LOGS_AVRO_BILLING_METRICS_MV",
"LOG_ATTRIBUTES2_TABLE_SQL",
diff --git a/posthog/clickhouse/logs/logs34.py b/posthog/clickhouse/logs/logs34.py
index 1e4e6ca2adef..ff201333b935 100644
--- a/posthog/clickhouse/logs/logs34.py
+++ b/posthog/clickhouse/logs/logs34.py
@@ -338,6 +338,34 @@ SETTINGS
"""
+def KAFKA_LOGS34_AVRO_MV_SELECT():
+ db = settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE
+ return f"""SELECT
+ uuid,
+ trace_id,
+ span_id,
+ trace_flags,
+ timestamp,
+ observed_timestamp,
+ body,
+ severity_text,
+ severity_number,
+ service_name,
+ instrumentation_scope,
+ event_name,
+ mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
+ mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
+ toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
+ observed_timestamp + toIntervalDay(toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))) AS original_expiry_timestamp,
+ _partition,
+ _topic,
+ _offset,
+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,
+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,
+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed
+FROM {db}.{KAFKA_TABLE_NAME}"""
+
+
def KAFKA_LOGS34_AVRO_MV():
db = settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE
return f"""
@@ -366,19 +394,7 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS {db}.kafka_logs34_avro_mv TO {db}.{TABLE_
`_bytes_uncompressed` Nullable(Int64),
`_bytes_compressed` Nullable(Int64)
)
-AS SELECT
- {KAFKA_TABLE_NAME}.* EXCEPT (created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),
- mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,
- mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,
- toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,
- observed_timestamp + toIntervalDay(toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))) AS original_expiry_timestamp,
- _partition,
- _topic,
- _offset,
- toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,
- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,
- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed
-FROM {db}.{KAFKA_TABLE_NAME}
+AS {KAFKA_LOGS34_AVRO_MV_SELECT()}
"""
diff --git a/posthog/clickhouse/migrations/0298_logs34_mv_explicit_columns.py b/posthog/clickhouse/migrations/0298_logs34_mv_explicit_columns.py
new file mode 100644
index 000000000000..f93986798178
--- /dev/null
+++ b/posthog/clickhouse/migrations/0298_logs34_mv_explicit_columns.py
@@ -0,0 +1,16 @@
+from django.conf import settings
+
+from posthog.clickhouse.client.connection import NodeRole
+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
+from posthog.clickhouse.logs import KAFKA_LOGS34_AVRO_MV_SELECT
+
+DB = settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE
+
+operations = [
+ run_sql_with_exceptions(
+ f"ALTER TABLE {DB}.kafka_logs34_avro_mv MODIFY QUERY\n{KAFKA_LOGS34_AVRO_MV_SELECT()}",
+ node_roles=[NodeRole.LOGS],
+ sharded=False,
+ is_alter_on_replicated_table=False,
+ ),
+]
diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txt
index b75f23b80c0a..a3e59dd17ae5 100644
--- a/posthog/clickhouse/migrations/max_migration.txt
+++ b/posthog/clickhouse/migrations/max_migration.txt
@@ -1 +1 @@
-0297_flag_evaluations_events_mirror
+0298_logs34_mv_explicit_columns