Skip to content

Commit c56816d

Browse files
authored
Sync Repos: for release 170.15.0 (#112)
* Merged PR 1534420: Added tests for Fuzzy String Matching Intrinsics Added tests for below Fuzzy String Matching functions: EDIT_DISTANCE EDIT_DISTANCE_SIMILARITY JARO_WINKLER_DISTANCE JARO_WINKLER_SIMILARITY ---- #### AI description (iteration 1) #### PR Classification New feature: Added tests for fuzzy string matching intrinsics. #### PR Summary This pull request introduces new tests for fuzzy string matching functions. - Added `FuzzyStringMatchingTests160.sql` with test cases for `EDIT_DISTANCE`, `EDIT_DISTANCE_SIMILARITY`, `JARO_WINKLER_DISTANCE`, and `JARO_WINKLER_SIMILARITY`. - Updated `Only160SyntaxTests.cs` to include the new test script with zero expected errors. - Added baseline file `FuzzyStringMatchingTests160.sql` for the new test cases. * Merged PR 1535135: Adding Regexp table valued functions parser tests Added Regexp TVFs to the sql script schema and added parser tests to validate in compatibility 170. Adding Regexp table valued functions parser tests ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request adds tests for Regexp table-valued functions (TVFs) in SQL Server. - Added `Only170SyntaxTests.cs` to include new parser tests for Regexp TVFs. - Updated `ParserTest.cs` to include a new `ParserTest170` class for handling SQL Server 170 syntax. - Added test scripts `RegexpTVFTests170.sql` under `Baselines170` and `TestScripts` directories to validate Regexp TVFs. - Modified `CodeGenerationSupporter.cs` to include constants for `REGEXP_MATCHES` and `REGEXP_SPLIT_TO_TABLE`. - Updated `TSql170.g` to recognize `REGEXP_MATCHES` and `REGEXP_SPLIT_TO_TABLE` as valid functions. Related work items: #3584646 * Merged PR 1537101: Adding missing eventname CREATE_VECTOR_INDEX Adding missing eventname CREATE_VECTOR_INDEX ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request adds support for the `CREATE_VECTOR_INDEX` event name in the T-SQL parser. - `SqlScriptDom/Parser/TSql/EventNotificationEventType.cs`: Added `CreateVectorIndex` event type with value 344. * [Security] Update .NET SDK to latest patch version * Merged PR 1548989: Adding Release notes for 170.12.0 and 170.15.0 Adding Release notes for 170.12.0 ---- #### AI description (iteration 1) #### PR Classification Documentation #### PR Summary This pull request adds release notes for version 170.12.0 of `Microsoft.SqlServer.TransactSql.ScriptDom`. - Added `release-notes/170.3/170.12.0.md` with details on target platform support, dependencies, and changes. - Notable changes include the removal of support for .NET Standard, dropping support for .NET 6, and adding support for .NET 8. ---------
1 parent d44ca9b commit c56816d

File tree

14 files changed

+212
-2
lines changed

14 files changed

+212
-2
lines changed

SqlScriptDom/Parser/TSql/CodeGenerationSupporter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ internal static class CodeGenerationSupporter
798798
internal const string RecursiveTriggers = "RECURSIVE_TRIGGERS";
799799
internal const string Recovery = "RECOVERY";
800800
internal const string Regenerate = "REGENERATE";
801+
internal const string RegexpMatches = "REGEXP_MATCHES";
802+
internal const string RegexpSplitToTable = "REGEXP_SPLIT_TO_TABLE";
801803
internal const string RejectType = "REJECT_TYPE";
802804
internal const string RejectSampleValue = "REJECT_SAMPLE_VALUE";
803805
internal const string RejectValue = "REJECT_VALUE";

SqlScriptDom/Parser/TSql/EventNotificationEventType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,11 @@ public enum EventNotificationEventType
10911091
/// </summary>
10921092
DropExternalLanguage = 331,
10931093

1094+
/// <summary>
1095+
/// CREATE_VECTOR_INDEX
1096+
/// </summary>
1097+
CreateVectorIndex = 344,
1098+
10941099
/// <summary>
10951100
/// AUDIT_LOGIN.
10961101
/// </summary>

SqlScriptDom/Parser/TSql/TSql170.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18966,7 +18966,7 @@ selectTableReferenceElementWithoutJoinParenthesis[SubDmlFlags subDmlFlags] retur
1896618966
{NextTokenMatches(CodeGenerationSupporter.ChangeTable)}?
1896718967
vResult=changeTableTableReference
1896818968
| vResult=builtInFunctionTableReference
18969-
| {NextIdentifierMatchesOneOf(new string[] {CodeGenerationSupporter.StringSplit, CodeGenerationSupporter.GenerateSeries})}?
18969+
| {NextIdentifierMatchesOneOf(new string[] {CodeGenerationSupporter.StringSplit, CodeGenerationSupporter.GenerateSeries, CodeGenerationSupporter.RegexpMatches, CodeGenerationSupporter.RegexpSplitToTable})}?
1897018970
vResult=globalFunctionTableReference
1897118971
| vResult=variableTableReference
1897218972
| vResult=variableMethodCallTableReference
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT EDIT_DISTANCE('sitting', 'kitten');
2+
SELECT EDIT_DISTANCE('sitting', 'kitten', 2);
3+
SELECT EDIT_DISTANCE_SIMILARITY('hello1', NULL);
4+
SELECT JARO_WINKLER_DISTANCE('', '');
5+
SELECT JARO_WINKLER_SIMILARITY('abcdefghij', 'jihgfedcba');
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
DECLARE @text AS VARCHAR (100) = 'abcabc';
2+
DECLARE @pattern AS VARCHAR (10) = 'a+';
3+
DECLARE @flags AS CHAR (1) = 'i';
4+
5+
SELECT *
6+
FROM REGEXP_MATCHES ('aaa', 'a');
7+
SELECT *
8+
FROM REGEXP_MATCHES ('hello', 'he(l+)o', 'i');
9+
SELECT *
10+
FROM REGEXP_MATCHES (@text, 'a');
11+
SELECT *
12+
FROM REGEXP_MATCHES (@text, @pattern, @flags);
13+
14+
SELECT *
15+
FROM REGEXP_SPLIT_TO_TABLE ('aaa', 'a');
16+
SELECT *
17+
FROM REGEXP_SPLIT_TO_TABLE ('hello', 'he(l+)o', 'i');
18+
SELECT *
19+
FROM REGEXP_SPLIT_TO_TABLE (@text, 'a');
20+
SELECT *
21+
FROM REGEXP_SPLIT_TO_TABLE (@text, @pattern, @flags);

Test/SqlDom/Only160SyntaxTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public partial class SqlDomTests
3838
new ParserTest160("TrimFunctionTests160.sql", nErrors80: 7, nErrors90: 7, nErrors100: 7, nErrors110: 7, nErrors120: 7, nErrors130: 7, nErrors140: 4, nErrors150: 4),
3939
new ParserTest160("JsonFunctionTests160.sql", nErrors80: 9, nErrors90: 8, nErrors100: 14, nErrors110: 14, nErrors120: 14, nErrors130: 14, nErrors140: 14, nErrors150: 14),
4040
new ParserTest160(scriptFilename: "IgnoreRespectNullsSyntaxTests160.sql", nErrors80: 12, nErrors90: 8, nErrors100: 8, nErrors110: 8, nErrors120: 8, nErrors130: 8, nErrors140: 8, nErrors150: 8),
41+
new ParserTest160(scriptFilename: "FuzzyStringMatchingTests160.sql", nErrors80: 0, nErrors90: 0, nErrors100: 0, nErrors110: 0, nErrors120: 0, nErrors130: 0, nErrors140: 0, nErrors150: 0),
4142
// OPENROWSET BULK statements specific to SQL Serverless Pools
4243
new ParserTest160(scriptFilename: "OpenRowsetBulkStatementTests160.sql", nErrors80: 8, nErrors90: 8, nErrors100: 8, nErrors110: 8, nErrors120: 8, nErrors130: 8, nErrors140: 8, nErrors150: 8),
4344
new ParserTest160(scriptFilename: "CreateStatisticsStatementTests160.sql", nErrors80: 4, nErrors90: 4, nErrors100: 4, nErrors110: 4, nErrors120: 4, nErrors130: 4, nErrors140: 4, nErrors150: 4),

Test/SqlDom/Only170SyntaxTests.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Microsoft.SqlServer.TransactSql.ScriptDom;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using SqlStudio.Tests.AssemblyTools.TestCategory;
4+
5+
namespace SqlStudio.Tests.UTSqlScriptDom
6+
{
7+
public partial class SqlDomTests
8+
{
9+
// Note: These filenames are case sensitive, make sure they match the checked-in file exactly
10+
private static readonly ParserTest[] Only170TestInfos =
11+
{
12+
new ParserTest170("RegexpTVFTests170.sql", nErrors80: 0, nErrors90: 0, nErrors100: 0, nErrors110: 0, nErrors120: 0, nErrors130: 0, nErrors140: 0, nErrors150: 0, nErrors160: 0)
13+
};
14+
15+
private static readonly ParserTest[] SqlAzure170_TestInfos =
16+
{
17+
// Add parser tests that have Azure-specific syntax constructs
18+
// (those that have versioning visitor implemented)
19+
//
20+
};
21+
22+
[TestMethod]
23+
[Priority(0)]
24+
[SqlStudioTestCategory(Category.UnitTest)]
25+
public void TSql170SyntaxIn170ParserTest()
26+
{
27+
// Parsing both for Azure and standalone flavors
28+
//
29+
TSql170Parser parser = new TSql170Parser(true);
30+
SqlScriptGenerator scriptGen = ParserTestUtils.CreateScriptGen(SqlVersion.Sql170);
31+
foreach (ParserTest ti in Only170TestInfos)
32+
{
33+
ParserTest.ParseAndVerify(parser, scriptGen, ti._scriptFilename, ti._result170);
34+
}
35+
36+
// Parsing both for Azure and standalone flavors - explicitly set
37+
// enum value to 'All'
38+
//
39+
parser = new TSql170Parser(true, SqlEngineType.All);
40+
scriptGen = ParserTestUtils.CreateScriptGen(SqlVersion.Sql170);
41+
scriptGen.Options.SqlEngineType = SqlEngineType.All;
42+
foreach (ParserTest ti in Only170TestInfos)
43+
{
44+
ParserTest.ParseAndVerify(parser, scriptGen, ti._scriptFilename, ti._result170);
45+
}
46+
47+
// Explicitly ask for 'standalone' and parse
48+
//
49+
parser = new TSql170Parser(true, SqlEngineType.Standalone);
50+
scriptGen = ParserTestUtils.CreateScriptGen(SqlVersion.Sql170);
51+
scriptGen.Options.SqlEngineType = SqlEngineType.Standalone;
52+
foreach (ParserTest ti in Only170TestInfos)
53+
{
54+
ParserTest.ParseAndVerify(parser, scriptGen, ti._scriptFilename, ti._result170);
55+
}
56+
}
57+
58+
}
59+
}

Test/SqlDom/ParserTest.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,43 @@ public ParserTest160(string scriptFilename, params ParserErrorInfo[] errors80And
465465
{ }
466466
}
467467

468+
internal class ParserTest170 : ParserTest
469+
{
470+
public ParserTest170(string scriptFilename, int nErrors80, int nErrors90, int nErrors100, int nErrors110, int nErrors120, int nErrors130, int nErrors140, int nErrors150, int nErrors160)
471+
: base(
472+
scriptFilename,
473+
new ParserTestOutput(nErrors80), new ParserTestOutput(nErrors90), new ParserTestOutput(nErrors100),
474+
new ParserTestOutput(nErrors110), new ParserTestOutput(nErrors120), new ParserTestOutput(nErrors130),
475+
new ParserTestOutput(nErrors140), new ParserTestOutput(nErrors150), new ParserTestOutput(nErrors160),
476+
new ParserTestOutput("Baselines170"))
477+
{ }
478+
479+
public ParserTest170(string scriptFilename, ParserTestOutput output80, ParserTestOutput output90, ParserTestOutput output100,
480+
ParserTestOutput output110, ParserTestOutput output120, ParserTestOutput output130, ParserTestOutput output140, ParserTestOutput output150, ParserTestOutput output160)
481+
: base(
482+
scriptFilename,
483+
output80, output90, output100,
484+
output110, output120,
485+
output130,
486+
output140,
487+
output150,
488+
output160,
489+
new ParserTestOutput("Baselines170"))
490+
{ }
491+
492+
public ParserTest170(string scriptFilename, params ParserErrorInfo[] errors80And90And100And110And120and130and140and150and160)
493+
: base(
494+
scriptFilename,
495+
new ParserTestOutput(errors80And90And100And110And120and130and140and150and160),
496+
new ParserTestOutput(errors80And90And100And110And120and130and140and150and160),
497+
new ParserTestOutput(errors80And90And100And110And120and130and140and150and160),
498+
new ParserTestOutput(errors80And90And100And110And120and130and140and150and160),
499+
new ParserTestOutput(errors80And90And100And110And120and130and140and150and160),
500+
new ParserTestOutput(errors80And90And100And110And120and130and140and150and160),
501+
new ParserTestOutput("Baselines170"))
502+
{ }
503+
}
504+
468505
internal class ParserTest80And90 : ParserTest
469506
{
470507
public ParserTest80And90(string scriptFilename, int nErrors100)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--EDIT_DISTANCE
2+
SELECT EDIT_DISTANCE('sitting', 'kitten');
3+
SELECT EDIT_DISTANCE('sitting', 'kitten', 2);
4+
5+
--EDIT_DISTANCE_SIMILARITY
6+
SELECT EDIT_DISTANCE_SIMILARITY('hello1', NULL);
7+
8+
--JARO_WINKLER_DISTANCE
9+
SELECT JARO_WINKLER_DISTANCE('', '');
10+
11+
--JARO_WINKLER_SIMILARITY
12+
SELECT JARO_WINKLER_SIMILARITY('abcdefghij', 'jihgfedcba');
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
DECLARE @text AS VARCHAR (100) = 'abcabc';
2+
DECLARE @pattern AS VARCHAR (10) = 'a+';
3+
DECLARE @flags AS CHAR (1) = 'i';
4+
5+
SELECT *
6+
FROM REGEXP_MATCHES ('aaa', 'a');
7+
SELECT *
8+
FROM REGEXP_MATCHES ('hello', 'he(l+)o', 'i');
9+
SELECT *
10+
FROM REGEXP_MATCHES (@text, 'a');
11+
SELECT *
12+
FROM REGEXP_MATCHES (@text, @pattern, @flags);
13+
14+
SELECT *
15+
FROM REGEXP_SPLIT_TO_TABLE ('aaa', 'a');
16+
SELECT *
17+
FROM REGEXP_SPLIT_TO_TABLE ('hello', 'he(l+)o', 'i');
18+
SELECT *
19+
FROM REGEXP_SPLIT_TO_TABLE (@text, 'a');
20+
SELECT *
21+
FROM REGEXP_SPLIT_TO_TABLE (@text, @pattern, @flags);

0 commit comments

Comments
 (0)