#106296·posthog

Native JSON events: cutover readiness tracker

Author: aspicerCreated Sep 24, 2026Updated Sep 30, 2026

Track the work left before enabling native JSON event reads and, later, retiring the legacy events table. Every item names work someone has to do and what done looks like. Do not put customer queries or private operational data here.

Where things stand (Sep 29)

Merged: the native schema and base property reads (#91515), correctness fixes (#104783), the retained mutation log (#97215), flag compatibility with the $false sentinel (#91506), the native CI lane (#106280), the HogQL port of point-in-time person properties (#91452), the UDF wrapper fix (#105651), and moved event properties read from temporary_properties (#107043).

In the merge queue: #106380 (native-only regression tests) is approved and joins the queue when its checks pass. #106274 (the useNewEventsSchema modifier, the rollout switch) left the queue on Sep 29 when a cancelled MCP run failed its batch, and needs to be queued again.

Open: #107546 moves the table to dynamic JSON paths, adds the null-key columns, turns date inference off, and stores dotted keys flat. The production table is re-backfilled after it lands. It conflicts with master, so its CI does not run until master is merged in. #106152 is open and listed below.

Rollout mechanism: staff set useNewEventsSchema in a project's team modifiers in Django admin. An explicit modifier is part of the query cache key, so the switch recomputes on native and clearing it restores the legacy cache entries. The final global flip uses the instance setting. Customers cannot set the key on their project (#106274); the per-query override stays available to API callers during the trial.

Before the backfill starts

  • Cleaner UDF and pin. The event cleaner stops expanding dotted keys into nested objects and encodes a dot inside a key segment as %2E in the null-key paths, so nested.deep and a flat key named a.b stay distinct. Rebuild the binaries and move the production UDF pin to a build with this, #105651 and the $false fix from #91506. Done when the pinned build is the one the backfill runs.
  • Backfill query. Recreate the table with the #107546 DDL, then copy every event with no retention cutoff, with the insert setting json_type_escape_dots_in_keys = 1, type_json_skip_duplicated_paths = 1, input_format_try_infer_dates = 0 and input_format_try_infer_datetimes = 0, the same four the ingestion view sets. Done when the copy runs with them.
  • AI prompt and response text. The native cleaner omits $ai_input and $ai_output_choices; the AI events table keeps that text only for its retention window, and older traces read it from the legacy table today. Get the LLM analytics owner's written agreement that older traces lose it, or a replacement source. The cleaner also drops $ai_output, $ai_input_state, $ai_output_state, $ai_tools and the four $feature_flag_*payload* keys (isDroppedEventProperty). The replay inspector reads $ai_tools, $ai_output and $feature_flag_payload from the event (AIEventItems.tsx, EventFlagsTab.tsx), and the AI credits /usage command reads $ai_output_state with raw SQL. Done when the answer covers the whole dropped list and is recorded here.
  • Repo matches the deployed ingestion path. Between the ingestion view and the data table, production has an intake table, two views that split rows by age, and buffer tables. posthog/models/event/sql.py defines none of them, and its view lacks the $feature_flag_called filter above. Recreating the table from #107546 has to recreate these too. Done when the repo's definitions produce the deployed path, or the difference is declared under posthog/clickhouse/hcl.

Before enabling native reads for any project

  • Read-side setting as a profile default on the events cluster. ClickHouse restores %2E to a dot only when the reading query sets json_type_escape_dots_in_keys. HogQL and the export templates set it per query (#107546, 0a9745adab5), but mutations run with server settings, and ad-hoc readers set nothing. Add it to the default profile on the events cluster. Done when a clickhouse-client session on that cluster prints a dotted key with a dot.
  • Rebuild nulls in whole-document reads. The JSON column cannot store null, so the cleaner drops those fields and #107546 records their paths in properties_null_keys, temporary_properties_null_keys and person_properties_null_keys. Nothing reads those arrays yet. Batch exports and the events API put the nulls back. Done when a native export and the events API return null for a fixture that sent one.
  • Dictionaries and tables on the events cluster. ClickHouse runs a native query on the events cluster's shards, and that cluster has no dictionaries. convertCurrency prints dictGetOrDefault(exchange_rate_dict, …) and the channel lookups print dictGetOrNull(channel_definition_dict, …) (posthog/hogql/printer/clickhouse.py), so trends with a revenue currency, revenue analytics over events, marketing conversion goals, first-pageview attribution and $virt_initial_channel_type fail with Dictionary not found (read-only check, Sep 30). A join or IN against ai_events fails the same way, because a single-shard table is not moved to the coordinator; the same holds for exchange_rate, pg_embeddings and the tables on the auxiliary cluster. The one-node test stack cannot catch this. Done when every dictionary and table HogQL can place in an events query resolves from an events-cluster shard, and a check compares the HogQL catalog with that cluster.
  • Freshness. Native rows become readable later than legacy rows because of the buffer tables in the deployed path. Measured Sep 30 on our own project by ingestion minute: rows under a minute old were 2% present on native, 32% at one to two minutes, 70% at two to three, and complete at four. Rows timestamped months back wait longer. The events explorer, the newest bucket of a chart and alerts on the current interval all read that window. Done when the lag is either accepted here with its number or reduced.
  • HogQL shapes that fail only on native. Three shapes return rows on the legacy table and an error on native. A JSON function with a key that is not a constant (JSONExtractString(properties, k) from a column, an ARRAY JOIN or a lambda, and JSONHas likewise) raises requires a constant first key (property_types.py, clickhouse_property_resolution.py). An array index on a property whose type varies between events (properties.arr.1 when one row holds a string) fails the whole query in arrayElement; legacy reads NULL for that row. JSONExtractString(properties, 'a%b') raises in posthog/hogql/printer/hogql.py for a key containing %. Separately, goe_N.properties.<key> prints a mat_gpN_* column that the native table lacks once such a column is materialized. #108943 fixes the four errors. Its array rewrite also changes indexed DateTime values from ISO strings with a UTC marker to ClickHouse wall-clock strings (reader). A synthetic local fixture parsed eight hours late in an America/Los_Angeles project. Done when the PR merges and indexed timestamp parity is preserved, or the #107546 backfill removes inferred DateTime values before native reads are enabled.
  • Demo projects. Creating a demo project copies events with COPY_EVENTS_BETWEEN_TEAMS, an INSERT … SELECT into writable_events that bypasses ingestion (products/demo/backend/logic/matrix/manager.py), so the native table never gets them. Done when the copy writes both tables or goes through ingestion.
  • Native CI lane covers experiments and cohorts. .github/new-events-schema-targets.txt still leaves out products/experiments, waiting on the flag map read that #91506 delivered, and products/cohorts is not listed. No test materializes a group-property column on events either. #108936 adds both directories. Done when it merges.
  • $feature_flag_called is read from flag_evaluations. The native table leaves this event out on purpose: the deployed ingestion view and the copy both exclude it, because the event is moving to the flag_evaluations table (#105446, history copy #108484, product surfaces #88126). Only the view in the repo (EVENTS_JSON_TABLE_MV_SQL) still keeps it. A project on native reads none from events, so experiments started before Sep 1 that still run (exposure_query_logic.py), the usage dashboard created for each flag (posthog/helpers/dashboard_templates.py) and saved insights on the event go empty. Done when a project's flag usage reads flag_evaluations and its history is copied there before the project switches, and the repo view carries the same filter. The history copy reads the legacy table, so it has to finish before legacy goes.
  • Land #106152, flag reads through JSON functions. JSONExtractRaw(properties, '$feature/x'), arrayJoin(JSONExtractArrayRaw(properties, '$active_feature_flags')), JSONLength, JSONType and toString(properties) do not see the rebuilt flags on native. It also has to decide how these functions tell a string variant named "true" from boolean true; the PR reads it as boolean true. Master is merged, and the PR no longer changes legacy-table SQL. Left: accept or change the "true" reading, mark it ready, get a HogQL review, land.
  • Decide the whole-document flag shape. On native, SELECT properties, the event properties panel and exports show flags as one $feature_flags object; the legacy table shows many $feature/<key> properties. Decide whether whole-document reads rebuild the legacy shape or expose the map, then implement it, including property restrictions and generated column aliases. The same shape reaches any read through a subquery or CTE: SELECT properties.$feature/x FROM (SELECT * FROM events) reads NULL on native, and so does a moved key such as properties.$set.email, because whole-document reads omit moved keys. A computed first key naming $feature/x raises in #108943 (RUNTIME_FEATURE_FLAG_KEY_ERROR in clickhouse_property_resolution.py) instead of reading the flag, until that read is routed through the flag JSON reads of #106152. If the map is exposed instead, EventPropertyTabs.tsx, EventFlagsTab.tsx and the toolbar's eventDebugMenuLogic.ts need to read it.
  • Batch exports. Pin exports to the legacy table now: the export source builds its query with the project's default modifiers, so switching a project would move its exports too. Before exports move: custom export columns are persisted as compiled ClickHouse expressions and schemas saved with property restrictions omit their original HogQL, so a saved export must recompile against the table it reads at run time; native exports serialize declared array paths as [] on every event; the native field rewrite relocates $feature/<key> paths but not JSON-function calls on them. Done when an export created before enablement, one created after, a restricted schema and a historical backfill all produce the same rows from both tables apart from the recorded expected differences.
  • Land #106380, native-only regression tests. Fixtures that exist only in the native table, with the legacy table asserted empty, so a query that fell back to legacy fails. Approved and submitted to the merge queue on Sep 29, covering the events-list boolean filters and daily trends. Done when it merges, before the first project switches.
  • Deletions cover the native table. #102195 skips sharded_events_json in deletes_job on purpose. Re-enable it, then run a catch-up over deletion requests already marked verified, because re-enabling does not revisit them. #99416 (draft) adds a two-cluster test. See deletion coverage.
  • person_id squash covers the native table. #105148 removed sharded_events_json from the weekly squash, so native rows keep the absorbed person_id and merged users count twice. Add the table back once its cluster resolves reliably, and repair rows stranded in the meantime, for example by copying person_id from the squashed legacy rows by uuid; the repair needs the legacy table. #98865 records the exclusion.
  • Property removal on the native table. Removing one property from all of a project's events is not implemented for the JSON columns. Implement it for properties, temporary_properties and person_properties, including $unparseable_properties. The deletion job reads a dot in a requested name as nesting on both tables; with dotted keys stored flat, the predicate, the verify step and the JSONDropKeys key list need the same %2E encoding to reach a flat dotted key (Sep 29 comment).
  • Compare and measure. Run the warm insights of the first trial project against both tables with the #106274 modifier and record the drift here, classified against the expected differences: empty and null values, JSON scalar types, number formatting (1.50 is stored as 1.5), flag arrays and order, omitted properties, deduplication; nulls and empty strings inside $set are dropped; object keys come back sorted; numbers above the signed 64-bit range inside an object read come back as JSON strings; an empty $set or $unset reads as missing; a key sent with a literal %2E reads back with a dot; an event carrying both a.b and a%2Eb keeps the first value; posthog-go before 1.13.2 listed off flags as active. Measure insert and merge cost with up to 1024 dynamic paths per part, and reads of wide objects past a column's dynamic-path budget (200k local synthetic events: a whole-object read of a wide $set took 20 s native against 0.8 s legacy, a $set.email filter read 9 MB against 177 MB). HogQL reads every native path through the generic Dynamic expression, even declared typed paths such as $browser; measure that too. Also compare the usage report counts on both tables before the global flip (posthog/tasks/usage_report.py reads the global setting, so billing moves with the flip and not with a project trial), and record the share of events whose document was quarantined into $unparseable_properties, since every property of such an event reads NULL. toFloat of a boolean property is 1 on native and NULL on legacy. Done when the numbers and the rollback criteria are written here.

Before retiring the legacy events table

Legacy writes stop and storage is dropped only after the items above and these are done.

  • Durable source for $set history. Point-in-time person properties (#91452) and the event details panel read $set and $set_once from old events. On native those live in temporary_properties for 60 days and in the mutation log (#97215) for 30, so anything older disappears with the legacy table. Choose a durable source or change the product contract, and finish #97217 against whichever it is.
  • Move the direct readers. About 45 files run raw SQL on events, sharded_events or events_recent and bypass the schema switch. The ones that read properties or legacy-only columns need a port: products/feature_flags/backend/flag_analytics.py; products/growth/backend/temporal/health_checks/sdk_outdated.py (mat_$lib); the MCP analytics metrics in posthog/tasks/usage_report.py (their dedup expression matches the legacy sort key); posthog/dags/person_property_reconciliation.py ($set from properties); rust/cohort-seeder/src/clickhouse/sql.rs with products/cohorts/backend/parity/; posthog/dags/events_backfill_to_duckling.py; posthog/models/web_preaggregated/sql.py and products/web_analytics/dags/cache_favicons.py (mat_* columns); the seven checks under products/web_analytics/backend/temporal/health_checks/; products/growth/dags/identity_matching.py; ee/hogai/chat_agent/slash_commands/commands/usage/queries.py; ee/billing/salesforce_enrichment/conversations_signals.py; and the events_recent readers (posthog/tasks/tasks.py, posthog/dags/property_definitions.py, posthog/clickhouse/custom_metrics.py). The rest only count rows and need the table name: posthog/models/event/util.py, posthog/clickhouse/system_status.py, the weekly digests, products/error_tracking/backend/ recommendations, products/signals/backend/scout_harness/suggestions.py, products/web_analytics/dags/cache_warming.py, ee/hogai/tools/read_billing_tool/tool.py, products/ai_observability/backend/ai_event_lookup.py, the batch export and group-type backfills, posthog/temporal/ingestion_acceptance_test/client.py, posthog/dags/deletes.py, posthog/models/data_deletion_request.py and posthog/query_scan/job.py. Move or retire each, then add the semgrep rule against new raw events SQL outside the switch.
  • Feeds built on the legacy table. In the repo, events_recent_json_mv, raw_sessions_mv, sessions_mv and the self-hosted raw_sessions_v3 view select from sharded_events (posthog/models/event/sql.py, posthog/models/raw_sessions/, posthog/models/sessions/sql.py). A deployment built from the migrations stops filling sessions and events_recent when legacy writes stop. Done when each reads the ingestion topic or the native table.
  • Backups. posthog/dags/backups.py lists sharded_events and not sharded_events_json. Done when the native table is backed up and a restore has been tried.
  • Retire legacy-only machinery. Materialized columns and dmat slots do nothing on the native table: ee/clickhouse/materialized_columns/, ee/tasks/materialized_columns.py, posthog/dags/backfill_materialized_column.py, posthog/temporal/backfill_materialized_property/. Direct writers need the same pass: bulk_create_events, posthog/local_bootstrap/importer.py and the data generators under posthog/management/commands/. Done when each is removed or writes the native table.

Done

  • #91515: native schema and base property reads.
  • #104783: native-mode correctness fixes and first coverage.
  • #97215: retained mutation-log storage.
  • #91506: flag compatibility layer and the $false sentinel. Historical rows whose variant was literally "false" are fixed by the re-backfill, which runs every row through the new cleaner.
  • #106280: continuous native-schema CI. Backend CI reruns the directories in .github/new-events-schema-targets.txt against the native table on every PR and in the merge queue.
  • #91452: point-in-time person properties through HogQL.
  • #105651: UDF wrapper closes inherited descriptors.
  • Sent types on declared paths: #107546 declares only low-cardinality strings, the flags map, the join keys and the cleaner-coerced arrays, so every other path keeps the type it was sent with. Effective with the re-backfill.
  • Date inference: #107546 turns it off and casts all three JSON columns explicitly inside the ingestion view, so a date string is stored and returned as the string it was. Effective with the re-backfill.
  • Dotted keys flat, application side: #107546 (0a9745adab5) sets json_type_escape_dots_in_keys and type_json_skip_duplicated_paths on the ingestion view and fixture inserts, HogQL encodes a dot inside a key segment as %2E on native reads, and native queries and export templates set the read-side setting. The cleaner and cluster parts are above.
  • Null keys recorded: #107546 writes dropped null paths to the three *_null_keys columns. Reading them back is above.

Keeping this tracker current

Consult this issue first when working on native JSON events. Add an item only when it names work someone has to do, with a code or PR reference and what done looks like. Check an item off when the work is in production, not when a PR merges. Keep merge decisions distin