Skip to content

Add validation for invalid METRIC when creating VECTOR INDEX - #6

Open
srodriguez-cenfotec wants to merge 4 commits into
cenfosoft:mainfrom
srodriguez-cenfotec:feature/HU-04
Open

srodriguez-cenfotec wants to merge 4 commits into
cenfosoft:mainfrom
srodriguez-cenfotec:feature/HU-04

Conversation

@srodriguez-cenfotec

@srodriguez-cenfotec srodriguez-cenfotec commented Oct 20, 2026 •

Copy link
Copy Markdown

Summary

Sql170 ad TSql180 have been updated to validate the cases where the clause has been added and no metric was defined

Implementation

  • Updated TSql170.g so missing-METRIC validation runs only when a WITH (...) clause is present.
  • Added the same validation to TSql180.g, which previously accepted WITH (TYPE = 'DiskANN') without METRIC.
  • Added parser checks for TSql170 and TSql180 covering a bare vector index, a WITH (METRIC = 'cosine') clause, a missing METRIC, and options without WITH retaining the SQL46010 syntax error.
  • Changed the existing TSql170 bare-index example and its baseline to omit WITH.

The grammar rules for T

TDD Evidence

RED: Without the validation, the focused test failed 1/1 because the validation was missing

Screenshot 2026-10-20 at 6 33 39 PM

GREEN: With the validation enabled, the same focused test passed 1/1.

Screenshot 2026-10-17 at 9 31 39 PM

Testing

Passed: dotnet test /p:TargetFramework=net8.0

@allancascante

Copy link
Copy Markdown

The missing-METRIC validation should only run when a WITH (...) clause is present. The syntax makes the entire clause optional, so a bare CREATE VECTOR INDEX ... should remain valid, while WITH (TYPE = DiskANN) should report the missing METRIC. As written, the check after the optional WITH clause rejects the bare form too.\n\nPlease apply the same validation to TSql180.g as well as TSql170.g; the latest parser has an independent vector-index rule and currently accepts WITH (TYPE = DiskANN) without an error.\n\nPlease add coverage for both parser versions: bare index succeeds; WITH (METRIC = cosine) succeeds; and WITH (TYPE = DiskANN) fails for missing METRIC. Also preserve the existing SQL46010 expectations for malformed syntax (e.g. options without WITH), so the new validation does not mask syntax errors. Given the optional clause, the baseline edits that add METRIC to bare-index examples should be reconsidered.

@srodriguez-cenfotec
srodriguez-cenfotec marked this pull request as ready for review October 21, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants