Skip to content

Validate VECTOR_DISTANCE dimensions in TSql170 - #2

Open
allancascante wants to merge 1 commit into
cenfosoft:mainfrom
allancascante:feature/vector-distance-dimension-validation
Open

allancascante wants to merge 1 commit into
cenfosoft:mainfrom
allancascante:feature/vector-distance-dimension-validation

Conversation

@allancascante

Copy link
Copy Markdown

Summary

  • Add T-SQL v170 AST validation for the fourth VECTOR_DISTANCE argument.
  • Report parse error 46146 when an integer dimension is outside the valid range of 1 through 1984.
  • Add an MSTest regression test for an invalid dimension of 0.

Implementation

  • Add Sql170ExpressionVisitor to inspect VECTOR_DISTANCE function calls.
  • Validate literal dimensions using invariant int.TryParse and C# pattern matching.
  • Run the visitor from TSql170Parser after parsing.
  • Return: Vector dimension must be an integer between 1 and 1984.

TDD Evidence

  • RED: With the visitor hook disabled, the focused test failed 1/1 at errors.Count > 0 because the parser returned no errors.
  • GREEN: With the visitor enabled, the same focused test passed 1/1.

Testing

Passed:

dotnet test Test/SqlDom/UTSqlScriptDom.csproj -c Debug -f net8.0 --filter "FullyQualifiedName~TestVectorDistance_InvalidDimension_ShouldReturnParseError"

The full net8.0 suite was started but canceled after test discovery. No test failure was reported before cancellation.

Code Changes

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.

1 participant