Refresh vector search samples for March 2026 product behavior - #24
Refresh vector search samples for March 2026 product behavior#24amthomas46 wants to merge 5 commits into
Conversation
- Quickstart scripts (diskann-quickstart-*) updated to the current VECTOR_SEARCH ... WITH APPROXIMATE syntax; add filler rows to satisfy the 100-row CREATE VECTOR INDEX minimum; remove the obsolete ALLOW_STALE_VECTOR_INDEX + rebuild-index-after-DML workflow. - Improvements script: rename approximate_staleness_percent -> graph_catchup_pending_percent (actual DMV name in the current build); safer IF EXISTS external-model drop; fix two syntax typos. - Wikipedia/006-fulltext-setup.sql: clearer full-text population timing note. - Wikipedia/008-semantic-reranking.sql + Semantic-Reranking/02-rerank.sql: Cohere Foundry deployment naming (v4.0 -> v4-0, no dots), trim payload to top-5 with LEFT(text,150) to fit GlobalStandard 1000 tokens/min cap. - Wikipedia/009-wikipedia-fp16.sql: idempotent DDL, cleaner rewrite. - Hybrid-Search/hybrid_search.py: fix CAST(? AS VECTOR) binding bug - double CAST(CAST(? AS NVARCHAR(MAX)) AS VECTOR(...)) is required with the ODBC driver's ntext binding. - RAG-with-Documents notebook: switch from pyodbc + manual Entra token struct to first-party mssql-python with authentication='ActiveDirectory Default'. Companion requirements.txt, .env.sample, Readme.md updates. - New sample: DiskANN/FineFoodReviews/ - end-to-end hybrid search over the Amazon Fine Food Reviews dataset (dataset already shipped in Datasets/finefoodembeddings.csv).
There was a problem hiding this comment.
Pull request overview
Updates the repository’s vector search + hybrid search samples to match March 2026 Azure SQL / SQL Server 2025 behavior (new VECTOR_SEARCH syntax and updated DMVs), migrates the RAG notebook to the first-party mssql-python driver, and adds a new end-to-end Fine Food Reviews hybrid-search sample.
Changes:
- Refresh DiskANN scripts for current
TOP (N) WITH APPROXIMATEsyntax and updatedsys.dm_db_vector_indexescounters. - Migrate RAG notebook/sample config from
pyodbctomssql-python, including the double-CAST(... AS NVARCHAR(MAX))workaround for VECTOR binding. - Add a new
DiskANN/FineFoodReviewshybrid-search sample (SQL scripts + helper Python loaders).
Reviewed changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Semantic-Reranking/02-rerank.sql | Updates vector-search syntax and trims rerank payload to fit Cohere token budget. |
| README.md | Adds pointer to the new FineFoodReviews hybrid-search sample. |
| RAG-with-Documents/requirements.txt | Swaps pyodbc dependency to mssql-python. |
| RAG-with-Documents/Readme.md | Updates library list to reference mssql-python. |
| RAG-with-Documents/RAG-with-resumes.ipynb | Migrates notebook connection/auth approach to mssql-python and applies double-cast VECTOR workaround. |
| RAG-with-Documents/.env.sample | Updates sample connection strings to remove ODBC-specific fields. |
| Hybrid-Search/hybrid_search.py | Applies double-cast workaround for VECTOR parameter binding with pyodbc. |
| DiskANN/Wikipedia/009-wikipedia-fp16.sql | Makes fp16 experiment script idempotent and updates vector-search syntax. |
| DiskANN/Wikipedia/008-semantic-reranking.sql | Clarifies rerank prereqs, updates deployment name format, trims payload for token budget. |
| DiskANN/Wikipedia/006-fulltext-setup.sql | Clarifies full-text population timing expectations (Hyperscale). |
| DiskANN/FineFoodReviews/README.md | Documents the new Fine Food Reviews hybrid-search scenario and run order. |
| DiskANN/FineFoodReviews/003-hybrid-search.sql | Adds side-by-side vector-only, full-text-only, and hybrid (RRF) queries. |
| DiskANN/FineFoodReviews/002-diskann-and-fulltext.sql | Adds DiskANN index build + full-text catalog/index setup for the sample. |
| DiskANN/FineFoodReviews/001-load-and-embed.sql | Adds sample load + AI_GENERATE_EMBEDDINGS step for 500 rows. |
| DiskANN/FineFoodReviews/000-setup.sql | Creates the reviews table and documents external model + data source setup. |
| DiskANN/FineFoodReviews/_load-reviews.py | Adds a Python helper to client-load CSV rows into dbo.reviews. |
| DiskANN/FineFoodReviews/_embed-reviews.py | Adds a Python helper to batch-embed rows server-side. |
| DiskANN/diskann-quickstart-sql-server-2025.sql | Adds filler rows for 100-row minimum and updates vector-search syntax. |
| DiskANN/diskann-quickstart-azure-sql.sql | Adds filler rows, updates syntax, and replaces stale-index workflow with DMV observation step. |
| DiskANN/diskann-quickstart-azure-sql-improvements.sql | Updates DMV column names and hardens external-model drop logic. |
| .gitignore | Ignores macOS .DS_Store and local session-prep folder. |
Comments suppressed due to low confidence (1)
DiskANN/FineFoodReviews/_embed-reviews.py:20
- The comment says "Set a long command timeout", but
SET LOCK_TIMEOUT 60000only controls how long the session waits on locks (in ms); it does not increase query/command timeout. This is misleading for readers troubleshooting timeouts fromAI_GENERATE_EMBEDDINGS.
# Set a long command timeout since AI_GENERATE_EMBEDDINGS is external
cur.execute("SET LOCK_TIMEOUT 60000;")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- FineFoodReviews/000-setup.sql + 002-diskann-and-fulltext.sql: name the primary-key constraint explicitly (PK_reviews) so the fulltext KEY INDEX binding is deterministic. Avoids the auto-generated PK__reviews__<hex> name that would otherwise fail on any fresh database. - FineFoodReviews/_load-reviews.py + _embed-reviews.py: replace hard-coded server/database/CSV path with MSSQL_SERVER / MSSQL_DATABASE / REVIEWS_CSV env vars (with safe placeholder + repo-relative defaults). No more developer-specific paths in the sample. - FineFoodReviews/_embed-reviews.py: clarify SET LOCK_TIMEOUT comment — it is a lock-wait cap, not a query/command timeout. - diskann-quickstart-azure-sql.sql + -sql-server-2025.sql: replace culture-sensitive FORMAT(..., 'N3') filler-vector formatting with CONVERT(varchar(5), CAST(x AS decimal(4,3))). Locale-invariant "." decimal separator, so the JSON-to-VECTOR cast is safe on any collation. - RAG-with-Documents/RAG-with-resumes.ipynb: clear all executed cell outputs and execution counts to shrink the diff and avoid checking in local run content (1754 -> 841 lines).
- RAG-with-resumes.ipynb: generate_completion() was treating each row of search_results as a single scalar (filename = result, chunkid = result, etc.), so the LLM grounding payload had every field set to the whole row tuple. Fixed to unpack the (filename, chunkid, chunk, similarity_score, distance_score) shape that vector_search_sql returns. - FineFoodReviews/_load-reviews.py: drop the misleading 'triggers AI_GENERATE_EMBEDDINGS server-side' line from the docstring — this script only loads rows; embedding happens in 001-load-and-embed.sql or _embed-reviews.py.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 21 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (8)
DiskANN/diskann-quickstart-azure-sql.sql:30
- This INSERT targets unqualified Articles even though the table is created as dbo.Articles. If the executing user’s default schema isn’t dbo, this can insert into/expect the wrong object. Qualify with dbo.
INSERT INTO Articles (id, title, content, embedding)
DiskANN/diskann-quickstart-azure-sql.sql:78
- This INSERT targets unqualified Articles but the table is dbo.Articles. Qualify the schema to avoid failures/accidental use of a different schema when the script is run under non-dbo default schemas.
INSERT INTO Articles (id, title, content, embedding)
DiskANN/diskann-quickstart-sql-server-2025.sql:43
- This INSERT targets unqualified Articles even though the table is created as dbo.Articles. Qualify with dbo to avoid schema-resolution issues when run under non-dbo default schemas.
INSERT INTO Articles (id, title, content, embedding)
DiskANN/diskann-quickstart-azure-sql.sql:50
- This CREATE VECTOR INDEX statement targets unqualified Articles even though the table is dbo.Articles. Qualifying the schema avoids failures when the executing user’s default schema isn’t dbo.
CREATE VECTOR INDEX vec_idx ON Articles(embedding)
WITH (METRIC = 'Cosine', TYPE = 'DiskANN')
DiskANN/diskann-quickstart-azure-sql.sql:64
- VECTOR_SEARCH is pointed at unqualified Articles even though the table is dbo.Articles. Use dbo.Articles so the sample behaves consistently regardless of the caller’s default schema.
VECTOR_SEARCH(
TABLE = Articles AS t,
COLUMN = embedding,
DiskANN/diskann-quickstart-azure-sql.sql:93
- This VECTOR_SEARCH call uses unqualified Articles, which can resolve to a different schema than dbo in some environments. Qualify with dbo to ensure the query targets the table created by the script.
VECTOR_SEARCH(
TABLE = Articles AS t,
COLUMN = embedding,
DiskANN/diskann-quickstart-sql-server-2025.sql:64
- This CREATE VECTOR INDEX statement targets unqualified Articles even though the table is created as dbo.Articles. Qualifying the schema avoids resolution issues under non-dbo default schemas.
CREATE VECTOR INDEX vec_idx ON Articles(embedding)
WITH (METRIC = 'Cosine', TYPE = 'DiskANN')
ON [PRIMARY];
DiskANN/diskann-quickstart-sql-server-2025.sql:77
- VECTOR_SEARCH is pointed at unqualified Articles even though the table is dbo.Articles. Use dbo.Articles to avoid schema-resolution issues when the script is run under users whose default schema isn’t dbo.
VECTOR_SEARCH(
TABLE = Articles AS t,
COLUMN = embedding,
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 21 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
DiskANN/diskann-quickstart-sql-server-2025.sql:31
- This script now mixes schema-qualified and unqualified references to the same table (e.g., dbo.Articles above vs Articles here). If the user's default schema is not dbo, this INSERT can fail or target an unexpected table. Use dbo.Articles consistently.
VALUES
(1, 'Intro to AI', 'This article introduces AI concepts.', '[0.1, 0.2, 0.3, 0.4, 0.5]'),
(2, 'Deep Learning', 'Deep learning is a subset of ML.', '[0.2, 0.1, 0.4, 0.3, 0.6]'),
(3, 'Neural Networks', 'Neural networks are powerful models.', '[0.3, 0.3, 0.3, 0.5, 0.1]'),
|
@Pookam90 when you get a chance, can you clone and test to update? I tried to update all the things listed at the top. Thanks! |
- Replace hard-coded Windows path with os.getenv("RESUME_FOLDER_PATH", ".")
- Remove separate loop that computed file_name only for the last file
- Compute file_name = os.path.basename(pdf_file) inside the enumerate loop
- Use pdf_file directly as pdf_path (already a full path from get_pdf_files)"
Brings the samples in line with the current Azure SQL / SQL Server 2025 vector search behavior (March 2026 update) and swaps the RAG notebook to the first-party
mssql-pythondriver.Product-behavior updates
DiskANN/diskann-quickstart-azure-sql.sqlandDiskANN/diskann-quickstart-sql-server-2025.sqlTOP_N =hint insideVECTOR_SEARCH(...)for the outerTOP (N) WITH APPROXIMATEsyntax.ALLOW_STALE_VECTOR_INDEX = ON+ rebuild-index-after-DML workflow. DML on an indexed table now works, and the graph is maintained asynchronously.sys.dm_db_vector_indexesobservation step showinggraph_catchup_pending_percent.DiskANN/diskann-quickstart-azure-sql-improvements.sqlapproximate_staleness_percent→graph_catchup_pending_percent(actual DMV column name).quantized_keys_used_percent,last_background_task_*counters.DROP EXTERNAL MODEL IF EXISTSfor a guardedIF EXISTS (SELECT 1 FROM sys.external_models …) DROP— avoids a syntax error on some builds.--for-.DiskANN/Wikipedia/006-fulltext-setup.sql: clearer note on full-text population timing on Hyperscale.DiskANN/Wikipedia/008-semantic-reranking.sqlandSemantic-Reranking/02-rerank.sqlCohere-rerank-v4.0-fast→Cohere-rerank-v4-0-fast.LEFT([text], 150)so we stay inside the Cohere GlobalStandard SKU's ~1000 tokens/min frontend cap.DiskANN/Wikipedia/009-wikipedia-fp16.sql: idempotent DDL (skip if the fp16 column / indexes already exist), cleaner formatting, expanded prereq notes.Driver + binding fix
Hybrid-Search/hybrid_search.py:CAST(? AS VECTOR(384))alone fails because the ODBC driver binds Python strings as ntext, and SQL Server won't coerce ntext directly into VECTOR. Fix is the double cast:CAST(CAST(? AS NVARCHAR(MAX)) AS VECTOR(384)).mssql-pythondriver migration in the RAG notebookRAG-with-Documents/RAG-with-resumes.ipynb: replacespyodbc+ manual Entra token struct with the first-partymssql-pythondriver, usingauthentication='ActiveDirectoryDefault'. Same functionality; no ODBC driver install required; native Entra ID support with no token juggling. Also applies the double-CAST fix to the INSERT andVECTOR_DISTANCEqueries so they work with the new driver.RAG-with-Documents/requirements.txt:pyodbc→mssql-python.RAG-with-Documents/.env.sample: drop the ODBC-specificDriver={ODBC Driver 18…}andLongAsMax=yesbits from the sample connection strings.RAG-with-Documents/Readme.md: one-word swap in the library-list sentence.New sample
DiskANN/FineFoodReviews/— end-to-end hybrid search over the Amazon Fine Food Reviews dataset (already shipped inDatasets/finefoodembeddings.csv).000-setup.sql— table + external model + optional external table for CSV load.001-load-and-embed.sql— load 500 rows and embed withAI_GENERATE_EMBEDDINGS.002-diskann-and-fulltext.sql— build the DiskANN vector index + full-text catalog/index oncombined.003-hybrid-search.sql— vector-only, full-text-only, and hybrid-RRF queries side by side.README.md+ Python helpers for a client-side CSV load path.README.mdpicks up one paragraph under#### DiskANN and Hybrid Searchlinking to it.Housekeeping
.gitignore: add.DS_Storeand a local session-prep folder (VSLive2026/).Testing
Validated against Azure SQL Hyperscale on a throwaway
pr_test_vector_searchdatabase (dropped after):diskann-quickstart-azure-sql.sqlend-to-end (10 batches)diskann-quickstart-sql-server-2025.sqlend-to-end (11 batches)USE <db>;skipped — Azure SQL limitation, works on SQL Server 2025)diskann-quickstart-azure-sql-improvements.sqlon a DB with the AI model set up (29 batches)<yourendpoint>before running)mssql-python+ double-CASTvector_search_sqlSELECT viamssql-python+ double-CASThybrid_search.pyVECTOR(384) INSERT + SELECT