I’m working on implementing hybrid search functionality using Azure SQL Database. I am trying to execute https://github.com/Azure-Samples/azure-sql-db-vector-search/blob/main/Hybrid-Search/hybrid_search.py and encountered the following error in my Python script:
pyodbc.DataError: (‘22018’, ‘[22018] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Explicit conversion from data type ntext to vector is not allowed. (529) (SQLExecDirectW); [22018] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)’)
Following is the simple SQL Statement which is failing
INSERT INTO dbo.documents (id, content, embedding) VALUES (?, ?, CAST(? AS VECTOR(384)));
This error occurs when executing a SQL query that involves vector operations. It appears that the embeddings are being treated as ntext, and the current setup doesn’t recognize the vector data type.
Environment Details:
- Python version: 3.11.x
- ODBC Driver: Microsoft ODBC Driver 18 for SQL
Server - Azure SQL Database
Steps Taken:
- Verified that the database schema defines the relevant column with the appropriate data type for storing vector embeddings.
- Ensured that the Python environment is using the latest version (18) of the ODBC driver.
- Confirmed that the SQL Server instance supports vector data types and operations.
1