Skip to content

Vector datatype issue #19151

Open
Open
@croblesm

Description

@croblesm

Interacting with the vector datatype causes the mssql extension to crash.

Here is a repro. Add a VECTOR column, update the data, then try to access the newly added data, this causes the extension to crash with the error below.

-- Example: Altering a Table to Add Vector Embeddings Column
ALTER TABLE [SalesLT].[Product]
ADD embeddings VECTOR(768), chunk NVARCHAR(2000);
GO

-- CREATE THE EMBEDDINGS
SET NOCOUNT ON;
DROP TABLE IF EXISTS #MYTEMP;
DECLARE @ProductID INT;
DECLARE @text NVARCHAR(MAX);

-- Create a temporary table with products that have NULL embeddings
SELECT * 
INTO #MYTEMP 
FROM [SalesLT].[Product] 
WHERE embeddings IS NULL;

-- Loop through all rows in the temporary table
WHILE EXISTS (SELECT 1 FROM #MYTEMP)
BEGIN
    -- Get the next ProductID from the temporary table
    SELECT TOP(1) @ProductID = ProductID 
    FROM #MYTEMP;

    -- Generate the text for embeddings
    SET @text = (
        SELECT p.Name + ' ' + ISNULL(p.Color, 'No Color') + ' ' + c.Name + ' ' + m.Name + ' ' + ISNULL(d.Description, '')
        FROM [SalesLT].[ProductCategory] c,
             [SalesLT].[ProductModel] m,
             [SalesLT].[Product] p
        LEFT OUTER JOIN [SalesLT].[vProductAndDescription] d
        ON p.ProductID = d.ProductID AND d.Culture = 'en'
        WHERE p.ProductCategoryID = c.ProductCategoryID AND p.ProductModelID = m.ProductModelID AND p.ProductID = @ProductID
    );

    -- Update the embeddings and chunk columns in the main table
    UPDATE [SalesLT].[Product]
    SET [embeddings] = get_embeddings(ollama, @text), 
        [chunk] = @text
    WHERE ProductID = @ProductID;

    -- Remove the processed row from the temporary table
    DELETE FROM #MYTEMP 
    WHERE ProductID = @ProductID;

    PRINT 'Processed ProductID: ' + CAST(@ProductID AS NVARCHAR(10)) + ' with text: ' + @text;
END;

USE  AdventureWorks2025;
GO

-- you cannot read the vector datatype in the vs code extension
select top 10 chunk, embeddings from SalesLT.Product

Here is the error you get
[Error - 3:19:15 PM] Request textDocument/definition failed. Message: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') Code: 0

Originally posted by @nocentino in #18946

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions