: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
chore(ducklake): raise events backfill target rows per file to 5M (#67581)
Jakob Homan87f3ae105c48
diff --git a/posthog/dags/events_backfill_to_duckling.py b/posthog/dags/events_backfill_to_duckling.pyindex a0c6c460cc91..fc9e1d674e2c 100644--- a/posthog/dags/events_backfill_to_duckling.py+++ b/posthog/dags/events_backfill_to_duckling.py@@ -604,7 +604,13 @@ BACKFILL_PERSONS_S3_PREFIX = "backfill/persons"# [1, MAX_S3_FILE_FANOUT]. Row count (not bytes) is the signal because it's the# dominant driver of file size and the only one ClickHouse estimates cheaply from# the primary key without scanning the wide columns; wide-row teams can be tuned via-# the per-run config. At ~4KB/event-row, 1M rows lands a file near ~4GB.+# the per-run config. At ~4KB/event-row, 5M rows lands a file near ~20GB.+#+# Larger files also mean fewer per-file DuckLake catalog commits: each Parquet+# file registered via `ducklake_add_data_files` is its own autocommit'd+# transaction, so the fan-out target directly sets the write-side commit rate+# a downstream reader (e.g. viaduck) has to contend with under DuckLake's+# per-table OCC.## MAX_S3_FILE_FANOUT is bounded by WRITER MEMORY, not file count: ClickHouse's# PartitionedSink keeps one Parquet writer open per active bucket for the whole@@ -615,7 +621,7 @@ BACKFILL_PERSONS_S3_PREFIX = "backfill/persons"# 256 × 128 MiB ≈ 32 GiB stays comfortably under the 100 GiB max_memory_usage ceiling.# N may exceed ClickHouse's max_partitions_per_insert_block (default 100) safely —# that limit gates MergeTree part creation, not the s3() PartitionedSink.-TARGET_ROWS_PER_FILE = 1_000_000+TARGET_ROWS_PER_FILE = 5_000_000MAX_S3_FILE_FANOUT = 256# Parquet writer settings shared by every export. The byte cap is the load-bearing one:diff --git a/posthog/dags/test_events_backfill_to_duckling.py b/posthog/dags/test_events_backfill_to_duckling.pyindex 2aa4f9aa9a2d..922ec3326b36 100644--- a/posthog/dags/test_events_backfill_to_duckling.py+++ b/posthog/dags/test_events_backfill_to_duckling.py@@ -1419,9 +1419,9 @@ class TestExportFanOut:return insert_sql, count_sql, s3_glob, clientdef test_events_export_sizes_fanout_to_row_count(self, target):- # 10M rows at the 1M-row default target → 10 files.+ # 50M rows at the 5M-row default target → 10 files.insert_sql, count_sql, s3_glob, _ = self._run_export(- export_events_to_duckling_s3, target, row_count=10_000_000, team_id=2, date=datetime(2026, 6, 17)+ export_events_to_duckling_s3, target, row_count=50_000_000, team_id=2, date=datetime(2026, 6, 17))assert "PARTITION BY toString(cityHash64(distinct_id) % 10)" in insert_sql# Count is filtered to exactly the team-day being exported.@@ -1459,8 +1459,9 @@ class TestExportFanOut:assert "PARTITION BY toString(cityHash64(distinct_id) % 5)" in insert_sqldef test_persons_daily_export_sizes_fanout_and_returns_glob(self, target):+ # 15M rows at the 5M-row default target → 3 files.insert_sql, count_sql, s3_glob, _ = self._run_export(- export_persons_to_duckling_s3, target, row_count=3_000_000, team_id=2, date=datetime(2026, 6, 17)+ export_persons_to_duckling_s3, target, row_count=15_000_000, team_id=2, date=datetime(2026, 6, 17))assert "PARTITION BY toString(cityHash64(distinct_id) % 3)" in insert_sql# Pin the full predicate: dropping is_deleted/date would silently over-size the fan-out.@@ -1468,8 +1469,9 @@ class TestExportFanOut:assert s3_glob == "s3://bkt/backfill/persons/2/year=2026/month=06/run1_*.parquet"def test_persons_full_export_sizes_fanout_and_returns_glob(self, target):+ # 25M rows at the 5M-row default target → 5 files.insert_sql, count_sql, s3_glob, _ = self._run_export(- export_persons_full_to_duckling_s3, target, row_count=5_000_000, team_id=2+ export_persons_full_to_duckling_s3, target, row_count=25_000_000, team_id=2)assert "PARTITION BY toString(cityHash64(distinct_id) % 5)" in insert_sqlassert "FROM person_distinct_id2 WHERE team_id = 2 AND is_deleted = 0" in count_sqldiff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambrindex 05cf7d90cf21..20eb045edd8c 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr@@ -1433,7 +1433,6 @@"posthog_team"."external_data_workspace_id","posthog_team"."external_data_workspace_last_synced_at","posthog_team"."api_query_rate_limit",- "posthog_team"."revenue_tracking_config","posthog_team"."drop_events_older_than","posthog_team"."base_currency","posthog_team"."experiment_recalculation_time",diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.pyindex f2c6fbf8b89c..dcb2200b3fe2 100644--- a/products/customer_analytics/backend/facade/api.py+++ b/products/customer_analytics/backend/facade/api.py@@ -719,7 +719,7 @@ def _definition_source_view(definition: CustomPropertyDefinition) -> contracts.C"""The source bound to this definition (reverse one-to-one ``source``), or None. List reads``select_related("source")`` so this stays a cache hit; detail reads pay one extra query."""try:- source = definition.source # type: ignore[attr-defined]+ source = definition.sourceexcept CustomPropertySource.DoesNotExist:return Nonereturn _to_custom_property_source_view(source)