You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Make VECTOR_SEARCH TOP_N parameter optional and add WITH (FORCE_ANN_ONLY) support
## Summary
Fixes ScriptDOM parser to correctly handle optional `TOP_N` parameter and `WITH (FORCE_ANN_ONLY)` query hint in `VECTOR_SEARCH` syntax, aligning with SQL Server 2025 behavior.
## Changes
**Grammar (TSql170.g)**
- Made `TOP_N` parameter optional
- Added `WITH (FORCE_ANN_ONLY)` clause parsing
**AST & Script Generator**
- Added `ForceAnnOnly` boolean to `VectorSearchTableReference`
- Updated script generator for nullable `TOP_N` and `WITH` clause output
- Full round-trip fidelity maintained
**Tests**
- Added `VectorSearchOptionalTopNTests170.sql` (4 test scenarios)
- Removed obsolete error test expecting mandatory `TOP_N`
## Example Syntax Now Supported
```sql
-- Without TOP_N
SELECT * FROM VECTOR_SEARCH(...) AS ann
-- With query hint
SELECT * FROM VECTOR_SEARCH(...) WITH (FORCE_ANN_ONLY) AS ann
-- With TOP_N (backward compatible)
SELECT * FROM VECTOR_SEARCH(..., TOP_N = 10) AS ann
```
Backward compatible - No breaking changes.
-**Exact syntax verification** (Exact T-SQL from user requests is tested precisely)
862
+
-**Round-trip fidelity validation** (Baseline preserves all input syntax unless documented)
811
863
812
864
Following these guidelines ensures robust test coverage for parser functionality and prevents regressions when adding new features or fixing bugs.
813
865
814
-
**Key Principle**: Always test the exact T-SQL syntax provided in user prompts or requests to verify that the specific syntax works as expected, rather than testing generalized or simplified versions of the syntax.
866
+
**Key Principles**:
867
+
1. Always test the exact T-SQL syntax provided in user prompts or requests
0 commit comments