fix: normalize incremental cursor values in drivers before persisting state#907
fix: normalize incremental cursor values in drivers before persisting state#907vishalm0509 wants to merge 10 commits into
Conversation
|
|
||
| var maxPrimaryCursorValue, maxSecondaryCursorValue any | ||
|
|
||
| bytesConverter := func(value any) any { |
There was a problem hiding this comment.
For now, instead of removing this entirely, let’s add an MSSQL-specific check; otherwise, we’d need to test all other drivers.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
I have also verified with 3 models
There was a problem hiding this comment.
IMO, for now we should implement for mssql only
| return utils.ConvertToString(value) | ||
| } | ||
|
|
||
| func normalizeMSSQLValueForState(value any, columnType string) any { |
There was a problem hiding this comment.
| func normalizeMSSQLValueForState(value any, columnType string) any { | |
| func normalizeMSSQLValue(value any, columnType string) any { |
| } | ||
|
|
||
| func (m *MSSQL) normalizeCursorValue(ctx context.Context, stream types.StreamInterface, cursorField string, value any) (any, error) { | ||
| if cursorField == "" || value == nil { |
There was a problem hiding this comment.
do we need this check as cursorField is never going to be empty
There was a problem hiding this comment.
No need to check cursorField
…ix/mssql_incremental
| if err := m.client.QueryRowContext(ctx, jdbc.MSSQLColumnTypeQuery(), stream.Namespace(), stream.Name(), cursorField).Scan(&dataType); err != nil { | ||
| return nil, fmt.Errorf("failed to get MSSQL cursor type: %s", err) |
There was a problem hiding this comment.
we already have a function in backfill for same
getColumnTypeMSSQL
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
How Has This Been Tested?
Screenshots or Recordings
Documentation
Related PR's (If Any):