Skip to content

fix: normalize incremental cursor values in drivers before persisting state#907

Open
vishalm0509 wants to merge 10 commits intostagingfrom
fix/mssql_incremental
Open

fix: normalize incremental cursor values in drivers before persisting state#907
vishalm0509 wants to merge 10 commits intostagingfrom
fix/mssql_incremental

Conversation

@vishalm0509
Copy link
Copy Markdown
Collaborator

@vishalm0509 vishalm0509 commented Apr 6, 2026

Description

The shared JDBC helper no longer converts scanned cursor values (e.g. []byte → string). It returns raw values; each source normalizes before writing state.

Postgres, MySQL, DB2: normalize by turning []byte cursors into strings.
MSSQL: normalize using column type (existing normalizeMSSQLValueForState) so incremental state matches what the backfill path uses.

Why
Central conversion was wrong or insufficient for some drivers/types; normalization must be driver- and type-aware (especially MSSQL).

Fixes # (issue)

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?

  • Scenario A
  • Scenario B

Screenshots or Recordings

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):

@vishalm0509 vishalm0509 changed the title fix: normalize state value for incremental sync mode - mssql fix: normalize incremental cursor values in drivers before persisting state Apr 6, 2026
@vishalm0509 vishalm0509 changed the base branch from master to staging April 6, 2026 10:13
@vishalm0509 vishalm0509 temporarily deployed to integration_tests April 9, 2026 11:21 — with GitHub Actions Inactive
Comment thread pkg/jdbc/jdbc.go

var maxPrimaryCursorValue, maxSecondaryCursorValue any

bytesConverter := func(value any) any {
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.

For now, instead of removing this entirely, let’s add an MSSQL-specific check; otherwise, we’d need to test all other drivers.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It will not break anything. As there is no change in the code flow. I am doing the same thing now but in a different place

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have also verified with 3 models

Copy link
Copy Markdown
Collaborator

@vikaxsh vikaxsh Apr 14, 2026

Choose a reason for hiding this comment

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

IMO, for now we should implement for mssql only

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Okay. Done

Comment thread drivers/mssql/internal/backfill.go Outdated
return utils.ConvertToString(value)
}

func normalizeMSSQLValueForState(value any, columnType string) any {
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.

Suggested change
func normalizeMSSQLValueForState(value any, columnType string) any {
func normalizeMSSQLValue(value any, columnType string) any {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread drivers/mssql/internal/incremental.go Outdated
}

func (m *MSSQL) normalizeCursorValue(ctx context.Context, stream types.StreamInterface, cursorField string, value any) (any, error) {
if cursorField == "" || value == nil {
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.

do we need this check as cursorField is never going to be empty

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No need to check cursorField

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.

2 participants