Complete Vector feature v2 (float16) serialization and bulk copy support - #365
Draft
Shiwani Gupta (shiwanigupta0809) wants to merge 3 commits into
Draft
Complete Vector feature v2 (float16) serialization and bulk copy support#365Shiwani Gupta (shiwanigupta0809) wants to merge 3 commits into
Shiwani Gupta (shiwanigupta0809) wants to merge 3 commits into
Conversation
Copilot started reviewing on behalf of
Shiwani Gupta (shiwanigupta0809)
August 24, 2026 09:03
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Completes float16 Vector v2 write support in mssql-tds.
Changes:
- Adds float16 serialization and bulk-copy metadata.
- Defaults vector negotiation to v2.
- Expands unit and integration coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
mssql-tds/src/connection/client_context.rs |
Defaults vector negotiation to v2. |
mssql-tds/src/datatypes/bulk_copy_metadata.rs |
Generates float16 vector DDL. |
mssql-tds/src/datatypes/sql_vector.rs |
Tests float16 construction and limits. |
mssql-tds/src/datatypes/tds_value_serializer.rs |
Serializes float16 elements. |
mssql-tds/src/message/features/vectorfeature.rs |
Tests v2 acknowledgement. |
mssql-tds/tests/common/mod.rs |
Supports configurable test databases. |
mssql-tds/tests/test_bulk_copy_vector.rs |
Adds float16 bulk-copy tests. |
mssql-tds/tests/test_vector_type.rs |
Adds float16 integration tests. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3804
to
+3814
| // 0.1 is not representable in f16; nearest half is 0x2E66. | ||
| let vector = crate::datatypes::sql_vector::SqlVector::try_from_f16(vec![0.1]).unwrap(); | ||
| let ctx = vector_ctx(8 + 2); | ||
| block_on(TdsValueSerializer::serialize_value( | ||
| &mut w, | ||
| &ColumnValues::Vector(vector), | ||
| &ctx, | ||
| )) | ||
| .unwrap(); | ||
| let p = payload(&w); | ||
| assert_eq!(&p[10..12], &0x2E66u16.to_le_bytes()); |
| } | ||
| VectorData::Float16(_) => { | ||
| todo!("Phase 2: Float16 serialization"); | ||
| VectorData::Float16(vs) => { |
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.
Description
Completes Phase 2 of Vector feature v2 (float16) support in
mssql-tds. Phase 1(feature negotiation and deserialization) landed in PR 7493 and left
todo!("Phase 2: Float16 serialization")in the value serializer, so float16vectors could be read from the server but not written back. This PR implements
the write path and enables float16 by default.
Serialization —
tds_value_serializer.rsreplaces thetodo!()with a realimplementation that narrows
f32values to IEEE 754 half-precision usinground-to-nearest-even (via the
halfcrate), matching the msodbcsql referencedriver's
Float32ToFloat16Bits. Elements are written little-endian, 2 bytes each,behind the standard 8-byte vector header.
Bulk copy —
bulk_copy_metadata.rsnow emitsvector(N, float16)in generatedDDL when the column's base type is float16. Previously it always emitted
vector(N), which SQL Server interprets as float32, so bulk copy of float16columns produced a type mismatch.
Default version —
client_context.rsflips the defaultVectorVersionfromV1toV2, resolving the// TODO: make V2 as default when full V2 support is addedleft by Phase 1. Version negotiation is unchanged: the client advertisesv2, and the server may still ack v1, in which case behavior is identical to today.
Tests
round-to-nearest-even behavior (
0.1f32→0x2E66)SqlVectortests fortry_from_f16and the higher float16 dimension ceiling(3996 vs. 1998)
parameters, NULL handling, max dimensions, precision loss, mixed base types,
and bulk copy
mssql-tds/tests/common/mod.rsnow honors aDB_DATABASEenv var so integrationtests can target a database with
PREVIEW_FEATURES = 1enabled, defaulting tomasteras before.Related Issues
https://sqlclientdrivers.visualstudio.com/mssql-rs/_workitems/edit/45020
https://sqlclientdrivers.visualstudio.com/mssql-rs/_workitems/edit/45021
Checklist
cargo bfmtpassescargo bclippypassescargo btestpasses