Skip to content

fix: auto select cursor field for default incremental sync mode (#976)#985

Open
Saquib1973 wants to merge 10 commits into
datazip-inc:stagingfrom
Saquib1973:fix-auto-select-cursor-field
Open

fix: auto select cursor field for default incremental sync mode (#976)#985
Saquib1973 wants to merge 10 commits into
datazip-inc:stagingfrom
Saquib1973:fix-auto-select-cursor-field

Conversation

@Saquib1973

Copy link
Copy Markdown
Contributor

Description

Automatically assigns the first available cursor field when the default sync mode is INCREMENTAL during the discovery phase. Additionally, updates mergeCatalogs to prevent an old catalog's empty cursor field from overwriting the newly auto-selected default, while still preserving explicit user choices.

Fixes #976

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Tested locally using a PostgreSQL database configured without CDC support to force the INCREMENTAL fallback.

  • Ran the discover command on PostgreSQL to verify streams.json correctly populates the cursor_field with the 0th available field instead of an empty string.
  • Ran the sync command on PostgreSQL to confirm the pipeline executes successfully without the zero-length delimited identifier SQL error.
  • Tested the merge stream catalog functionality to ensure that newly generated default cursor fields are not overwritten by empty strings from legacy catalogs.

Screenshots or Recordings

2026-06-11.23-21-05.mp4

Documentation

  • Documentation Link: [link to README, olake.io/docs, or olake-docs]
  • N/A (bug fix, refactor, or test changes only)

Related PR's (If Any):

None

@CLAassistant

CLAassistant commented Jun 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Saquib1973

Copy link
Copy Markdown
Contributor Author

@nayanj98 my pr is ready for review

@nayanj98

Copy link
Copy Markdown
Collaborator

Assigning @vaibhav-datazip to review your PR

@nayanj98 nayanj98 requested a review from vaibhav-datazip June 12, 2026 13:24
convStream.SyncMode = types.CDC
} else if convStream.SupportedSyncModes.Exists(types.INCREMENTAL) {
convStream.SyncMode = types.INCREMENTAL
if convStream.CursorField == "" && convStream.AvailableCursorFields.Len() > 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't cursorField = "" guard redundant ?
also can you add a crisp and clear comment here why this has been added and how it helps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the issue, user can select cursorField during discover

  • If cursorField already filled skip
  • If the cursorField is empty and there is a availableCursorFields, set cursrorField to the first availableCursorField

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I am saying can this ever happen that we get cursorField as non empty in discover function here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Discover(), every column is added to AvailableCursorFields using WithCursorField() while generating productSchema, but cursorField is never set.

Comment thread types/catalog.go
Comment on lines +148 to +150
if oldStream.Stream.CursorField != "" {
newStream.Stream.CursorField = oldStream.Stream.CursorField
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a test case for this in catalog_test as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a test case : Saquib1973@7eb4c62

Comment thread drivers/abstract/abstract.go
hash-data and others added 2 commits June 16, 2026 16:00
Signed-off-by: nayanj98 <nayan@datazip.io>
Co-authored-by: nayanj98 <nayan@datazip.io>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants