: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
fix(warehouse-sources): apply cdc truncates to tables stored under a bare name (#106149)
Daniel RCffcfed7fdbe6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.py b/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.pyindex 030f18801a62..050f9a20722b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.py+++ b/products/warehouse_sources/backend/temporal/data_imports/cdc/activities.py@@ -1425,8 +1425,11 @@ class CDCExtractActivity:"""truncated_tables = list(self.reader.truncated_tables)self.reader.clear_truncated_tables()+ # The decoder names a table `schema.table`, while a schema created with a source schema set is+ # stored bare, so the lookup goes through the same map as the change events.+ stored_names = self._build_event_name_map()for table_name in truncated_tables:- trunc_schema = self.schema_by_name.get(table_name)+ trunc_schema = self.schema_by_name.get(stored_names.get(table_name, table_name))if trunc_schema is None:continueself._schema_log(trunc_schema).warning(diff --git a/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.py b/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.pyindex e0376a368c0d..74361b1ae70c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.py+++ b/products/warehouse_sources/backend/temporal/data_imports/cdc/tests/test_extract_activity.py@@ -1457,6 +1457,8 @@ class TestCDCExtractActivity:assert schema.initial_sync_complete is Falsemock_reader.confirm_position.assert_called_once_with("0/500")+ # The decoder reports a truncated table qualified, even when the schema is stored bare.+ @parameterized.expand([("bare", "users"), ("qualified_as_the_decoder_reports_it", "public.users")])@patch("products.warehouse_sources.backend.temporal.data_imports.cdc.activities.unpause_external_data_schedule",create=True,@@ -1471,6 +1473,8 @@ class TestCDCExtractActivity:@patch("products.warehouse_sources.backend.temporal.data_imports.cdc.activities.close_old_connections")def test_truncate_sets_snapshot_mode(self,+ _name,+ truncated_name,mock_close_conns,MockJob,MockSourceModel,@@ -1499,8 +1503,7 @@ class TestCDCExtractActivity:events,)- # Simulate a truncate for the "users" table- mock_reader.truncated_tables = ["users"]+ mock_reader.truncated_tables = [truncated_name]inputs = CDCExtractInput(team_id=1, source_id=source.id)cdc_extract_activity(inputs)