My Configuration
I have a stream configured to capture changes from a Cloud SQL Postgres source and writing to a BigQuery destination. The change data are written to a BigQuery table with write mode set to Append-only.
The Incident
One day I found out the datastream service account executed the following SQL statement to BigQuery.
It started with a SELECT statement:
2025-09-02 20:36:15.716000 UTC
"SELECT kcu.column_name FROM `xxxx`.INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc JOIN `xxxx`.INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS kcu ON
tc.constraint_name = kcu.constraint_name
AND tc.table_catalog = kcu.table_catalog
AND tc.table_schema = kcu.table_schema
AND tc.table_name = kcu.table_name
WHERE tc.table_name = 'table_name' AND tc.constraint_type = 'PRIMARY KEY';"
Then shortly after the primary key was dropped by an ALTER statement.
2025-09-02 20:36:20.722000 UTC
ALTER TABLE `xxxx.table_name` DROP PRIMARY KEY
This happened for multiple tables, but not the entirety of the CDC tables. The primary key dropping lasted for ~48 hours and it stopped.
Datastream log
From datastream log, right after the primary keys being dropped, there is a Completed writing log entry for the corresponding tables.
INFO 2025-09-02T20:36:22.463157Z Completed writing 1 records into xxxx.table_name.
Source Database
I confirmed with the DBA that there is no schema change during that time period. It is worth mentioning that there is a scheduled reindex in Cloud SQL every weekend that involves most of the CDC tables, but the primary key in BigQuery where dropped in weekdays.
Unfortunately, I was too late to inspect the WAL log as they are rotated.
My Question
The primary keys were initially set by datastream when it created the destination tables in BigQuery. I want to understand whether this is a normal behavior, and what is the reason behind it?