Repository navigation
source-mssql: Fix primary key discovery and clustered index handling - #69194
Merged
Merged
Conversation
Contributor
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Helpful Resources
PR Slash CommandsAirbyte Maintainers (that's you!) can execute the following slash commands on your PR:
|
Contributor
|
Wenqi Hu (burakku)
force-pushed
the
wenqi-mssql-rollout-fix-3
branch
2 times, most recently
from
November 5, 2025 23:42
788ae4e to
10865d1
Compare
Contributor
|
Deploy preview for airbyte-docs ready! ✅ Preview Built with commit 89504bf. |
Wenqi Hu (burakku)
force-pushed
the
wenqi-mssql-rollout-fix-3
branch
from
November 6, 2025 22:55
10865d1 to
88f4b04
Compare
sophiecuiy
self-requested a review
November 6, 2025 23:03
sophiecuiy
approved these changes
Nov 6, 2025
Wenqi Hu (burakku)
force-pushed
the
wenqi-mssql-rollout-fix-3
branch
from
November 7, 2025 00:57
88f4b04 to
43047a2
Compare
Wenqi Hu (burakku)
force-pushed
the
wenqi-mssql-rollout-fix-3
branch
from
November 7, 2025 18:36
4e5fcaa to
89504bf
Compare
sophiecuiy
pushed a commit
that referenced
this pull request
Nov 11, 2025
sophiecuiy
pushed a commit
that referenced
this pull request
Nov 14, 2025
2 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes critical issues in the MSSQL source connector related to primary key discovery, views support, and datetime precision after migration to the new CDK (version 4.3.0-rc.3).
Changes
1. Fix CI vs PK Selection (commit aa10bb9)
Problem:
Solution:
primaryKey()function to return the actual PRIMARY KEY constraint for discovery/catalog purposesgetOrderedColumnForSync()function to determine which column to use for syncing (prefers clustered index for performance)AND i.is_unique = 1filter to clustered index query to only use unique indexes for syncingMsSqlServerJdbcPartitionFactoryto usegetOrderedColumnForSync()instead of just using first PK columnBehavior:
(RegID, AgentID, assignedDate)and unique clustered index onRegID:RegID(from clustered index for performance)2. Fix TABLESAMPLE Error on Views (commit ab392d7)
Problem:
Root Cause:
MsSqlServerJdbcCursorPartitioninheritedsamplingQuery()method fromMsSqlServerJdbcResumablePartitionFromSamplewhich generates TABLESAMPLE queriesSolution:
samplingQuery()method inMsSqlServerJdbcCursorPartition(lines 428-442)FROMclause instead ofFromSampleFiles changed:
MsSqlServerJdbcPartition.kt: Added override ofsamplingQuery()method3. Fix DateTime Precision Issue (commit 4e5fcaa)
Problem:
datetime2can have up to 7 decimal places of precisionLocalDateTimeCodecalso expects exactly 6 decimal placesRoot Cause:
TimestampAccessorwhich preserves full precision from SQL ServerLocalDateTimevalues with 7 decimal places were encoded to JSON, they exceeded BigQuery's limitMsSqlServerDebeziumConverterusingoutputDateFormatterwith 6 decimalsSolution:
MsSqlServerLocalDateTimeAccessorthat truncates datetime values to microsecond precision (lines 122-141)(localDateTime.nano / 1000) * 1000- zeros out nanoseconds beyond microsecondsMsSqlServerLocalDateTimeFieldType(lines 143-148)JDBCType.TIMESTAMP→MsSqlServerLocalDateTimeFieldType(line 94)MsSqlServerSqlType.DATETIME_TYPES→MsSqlServerLocalDateTimeFieldType(line 239)outputDateFormatterwith patternyyyy-MM-dd'T'HH:mm:ss.SSSSSS(6 decimals) ✅Files changed:
MsSqlSourceOperations.kt: Added custom datetime accessor and field type, updated mappingsTest Coverage
All 27 tests passing:
Backward Compatibility
These changes maintain complete feature parity with version 4.2.6:
Impact
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com