I have a main table and a staging table in GCP Bigquery. The main table will have the snapshot data and the staging table will be a streaming table. I want to run merge query and update the data in the main table at a certain intervals.
As I will be using the MongoDB Debezium connector, I will only be receiving updated columns for a row and the rest columns will be null.
The normal merge query will update the entire row which is undesirable.
I need an approach to merge the rows from the tables only for those specific columns and keep the rest of the columns untouched. The columns to be updated can be different for each row.
For eg :
Main table data:
id status login_id task_id user_id
71 CLAIMED 13 4373737 2191
Staging table data:
id status login_id task_id user_id
71 null null 4636282 null
I want result something like this:
id status login_id task_id user_id
71 CLAIMED 13 4636282 2191
The query must insert a record for a new key and update a specific column for the existing key.
Is it possible? Anyone can help me with that?