fix(backfill): populate cdc timestamp for snapshot records when cdc enabled - #1059
fix(backfill): populate cdc timestamp for snapshot records when cdc enabled#1059krishanu7 wants to merge 3 commits into
Conversation
chore: staging -> master v0.9.0
|
Hi @krishanu7 , maybe you understood the issue incorrectly. The issue states that if cdc is enabled, but the sync mode is full_refresh or incremental, the cdc_timestamp column comes in the destination table. The thing is when cdc is enabled (cdc config provided), the cdc timestamp column comes in the discover phase i.e. in streams.json. If the cdc timestamp column is present in streams.json, then it will always come whatever the sync mode and its value is. What we require is during discover even if the cdc is enabled we will not include cdc timestamp in the discover phase i.e. in streams.json. by default the sync mode is cdc, where user can change it to incremental or full refresh. If cdc sync mode, then we have to configure somehow during the sync running that cdc timestamp column and its respective value to be included. Otherwise if sync mode changed to full refresh or incremental (even if cdc enabled) , since in streams.json cdc timestamp not present, it won't come in destination table. also in case of s3 parquet destination specifically, i think cdc column in destination (null valued) always comes even if not in streams.json. so this has to be fixed as well here. |
|
@ImDoubD-datazip Hi, Thanks for explaing the requirement, i updated code and raised new PR #1068 can you please review this |
Description
This PR resolves an issue where the
_cdc_timestampmetadata column was generated asnull(or missing values) during the initial backfill/snapshot phase when the source connector configuration had CDC enabled (cdc: true), but the sync mode was set toincrementalorfull_refresh.Key Changes
Updated
drivers/abstract/backfill.goto dynamically check the target schema. If the destination schema includes the_cdc_timestampcolumn, we write the Unix epoch1970-01-01 00:00:00 UTC(time.Unix(0, 0)) as a placeholder. This satisfies downstream schema constraints (e.g., Iceberg) and clearly marks historical snapshot rows from live CDC events.Fixes # (issue)
Type of change
How Has This Been Tested?
The changes were validated using a local multi-container test environment running Postgres source, MinIO S3 object storage, and an Apache Spark SQL engine connecting to the local Iceberg catalog.
cdc: trueis configured and the_cdc_timestampis present in the schema, the backfilled tables are successfully generated with1970-01-01 05:30:00+05:30instead ofnull(or failing due to Iceberg schema constraints)._cdc_timestampcolumn is stripped from the schema config, the sync successfully executes and writes the Parquet files without adding any unexpected_cdc_timestampdata columns (avoiding schema mismatch issues).Screenshots or Recordings
*** Test 1: CDC ON (Schema contains _cdc_timestamp) ***
For this run, we used streams.json which includes _cdc_timestamp in the catalog schema definition.
*** Test 2: CDC OFF (Schema does NOT contain _cdc_timestamp) ***
Documentation
Related PR's (If Any):
None