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(property-vals): drop length filter from property_values mv (#61323)

Andy Zhaoee37a3b5bb95
diff --git a/posthog/clickhouse/migrations/0270_property_values_drop_mv_length_filter.py b/posthog/clickhouse/migrations/0270_property_values_drop_mv_length_filter.py
new file mode 100644
index 000000000000..e888a00b3ce7
--- /dev/null
+++ b/posthog/clickhouse/migrations/0270_property_values_drop_mv_length_filter.py
@@ -0,0 +1,18 @@
+from posthog import settings
+from posthog.clickhouse.client.connection import NodeRole
+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
+from posthog.clickhouse.property_values import DROP_PROPERTY_VALUES_MV_SQL, PROPERTY_VALUES_MV_SQL
+
+# Length and empty-value filtering now lives in the property-vals service, so the
+# MV passes everything from the Kafka table straight through. property_values lives
+# on AUX in prod but on DATA in dev (dev's aux nodes don't host it), matching
+# 0262/0268. Single-node local/hobby get overridden to ALL by the migration runner.
+if settings.CLOUD_DEPLOYMENT == "DEV":
+ _ROLES = [NodeRole.DATA]
+else:
+ _ROLES = [NodeRole.AUX]
+
+operations = [
+ run_sql_with_exceptions(DROP_PROPERTY_VALUES_MV_SQL(), node_roles=_ROLES),
+ run_sql_with_exceptions(PROPERTY_VALUES_MV_SQL(), node_roles=_ROLES),
+]
diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txt
index eb9e1da83014..c36dd7acdc01 100644
--- a/posthog/clickhouse/migrations/max_migration.txt
+++ b/posthog/clickhouse/migrations/max_migration.txt
@@ -1 +1 @@
-0269_ensure_metric_events_preaggregated
+0270_property_values_drop_mv_length_filter
diff --git a/posthog/clickhouse/property_values.py b/posthog/clickhouse/property_values.py
index fbb3e3033ce3..8bfc72f45ed7 100644
--- a/posthog/clickhouse/property_values.py
+++ b/posthog/clickhouse/property_values.py
@@ -86,10 +86,6 @@ AS SELECT
property_count,
coalesce(_timestamp, now()) as last_seen
FROM {database}.{kafka_table}
-WHERE lengthUTF8(property_key) > 0
- AND lengthUTF8(property_key) <= 400 -- matches Django PropertyDefinition.name max_length
- AND lengthUTF8(property_value) > 0
- AND lengthUTF8(property_value) < 256
""".format(
mv_name=MV_NAME,
table_name=TABLE_NAME,
diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
index 9a2afc30ebd8..ef0d754eeaf7 100644
--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr
+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
@@ -3751,10 +3751,6 @@
property_count,
coalesce(_timestamp, now()) as last_seen
FROM posthog_test.kafka_property_values
- WHERE lengthUTF8(property_key) > 0
- AND lengthUTF8(property_key) <= 400 -- matches Django PropertyDefinition.name max_length
- AND lengthUTF8(property_value) > 0
- AND lengthUTF8(property_value) < 256
'''
# ---