Merge commits until 161.8817.2 nuget version (#41) · feiyun0112/SqlScriptDOM@4b7e0af · GitHub
Skip to content

Commit 4b7e0af

Browse files
barbaravaldezllaliElavarasan Dhayalan
authored
Merge commits until 161.8817.2 nuget version (microsoft#41)
* Merged PR 1046749: Removing warnings for missing xml doc in test projects Removing warnings for missing xml doc in test projects * Merged PR 1048435: Defining a new property for AST.XML for connecting a single item to a collection Sometimes we need to change an existing SQL object property, which we already have support in Scriptdom, from one item property to a collection. This PR introduces a new property for AST file for adding a collection and connecting it to the existing property. This is to make sure we don't introduce breaking changes in. So using this new feature, we add a new collection and keep the current property but set CollectionFirstItem to true so in the generated file it gets and sets the first value of the collection. This is how generated code will look like using the new xml property: ` private List<Identifier> _distributionColumns = new List<Identifier>(); /// <summary> /// The column reference in the HASH option for a table distribution policy. /// </summary> public IList<Identifier> DistributionColumns { get { return _distributionColumns; } } /// <summary> /// The column reference in the HASH option for a table distribution policy. /// </summary> public Identifier DistributionColumn { get { return DistributionColumns.Count > 0 ? DistributionColumns[0] : null; } set { if (DistributionColumns.Count == 0) { DistributionColumns.Add(value); } else { DistributionColumns[0] = value; } } }` * Merged PR 1050712: Multiple Column Distribution Support in ScriptDom for Dw SqlTable Multiple Column Distribution Support in ScriptDom for Dw SqlTable 1. Added DistributionColumns member with Collection="true" attribute in TableHashDistributionPolicy class in AST.xml 2. CollectionFirstItem="true" attribute added in DistributionColumn member of TableHashDistributionPolicy class in AST.xml 3. tableHashDistributionPolicy updated with multiple columns(AddAndUpdateTokenInfo) in TSql130.g,TSql140.g,TSql150.g and TSql160.g 4. SqlScriptGeneratorVisitor.TableHashDistributionPolicy is modified with DistributionColumns 5. Modified CreateTableGeneratedAlwaysNegativeTest test method in ParserErrorsTests.cs DISTRIBUTION = HASH(COL1,,COL2) 5. Added create table scripts with MCD in following scripts files a. CreateTableTests*.sql in Baselines* and TestScripts folder. Related work items: #2346322 * Merged PR 1051494: Adding NetStandard2.0 target Adding NetStandard2.0 target --------- Co-authored-by: Leila Lali <llali@microsoft.com> Co-authored-by: Elavarasan Dhayalan <v-edhayalan@microsoft.com>
1 parent 7ffc71e commit 4b7e0af

26 files changed

Lines changed: 381 additions & 39 deletions

‎Directory.Build.props‎

Lines changed: 2 additions & 1 deletion

‎SqlScriptDom/Parser/TSql/Ast.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,8 @@
26972697
</Class>
26982698
<Class Name="TableHashDistributionPolicy" Base="TableDistributionPolicy" Summary="Representation of the HASH option for an table distribution policy.">
26992699
<InheritedClass Name="TableDistributionPolicy"/>
2700-
<Member Name="DistributionColumn" Type="Identifier" GenerateUpdatePositionInfoCall="false" Summary="The column reference in the HASH option for a table distribution policy."/>
2700+
<Member Name="DistributionColumn" Type="Identifier" CollectionFirstItem="true" GenerateUpdatePositionInfoCall="false" Summary="The columns reference in the HASH option for a table distribution policy."/>
2701+
<Member Name="DistributionColumns" Type="Identifier" Collection="true" GenerateUpdatePositionInfoCall="false" Summary="The column reference in the HASH option for a table distribution policy."/>
27012702
</Class>
27022703

27032704
<Class Name="TableIndexOption" Base="TableOption" Summary="Represents the table INDEX option for SQL DW tables.">

‎SqlScriptDom/Parser/TSql/TSql130.g‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25173,16 +25173,24 @@ tableHashDistributionPolicy returns [TableHashDistributionPolicy vResult = Fragm
2517325173
Identifier vIdentifier;
2517425174
}
2517525175
:
25176-
tHash:Identifier LeftParenthesis vIdentifier = identifier
25177-
{
25178-
Match(tHash, CodeGenerationSupporter.Hash);
25179-
vResult.DistributionColumn = vIdentifier;
25180-
UpdateTokenInfo(vResult, tHash);
25181-
}
25182-
tRParen:RightParenthesis
25183-
{
25184-
UpdateTokenInfo(vResult, tRParen);
25185-
}
25176+
tHash:Identifier
25177+
{
25178+
Match(tHash, CodeGenerationSupporter.Hash);
25179+
UpdateTokenInfo(vResult, tHash);
25180+
}
25181+
LeftParenthesis vIdentifier = identifier
25182+
{
25183+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
25184+
}
25185+
(Comma vIdentifier = identifier
25186+
{
25187+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
25188+
}
25189+
)*
25190+
tRParen:RightParenthesis
25191+
{
25192+
UpdateTokenInfo(vResult, tRParen);
25193+
}
2518625194
;
2518725195

2518825196
tableReplicateDistributionPolicy returns [TableReplicateDistributionPolicy vResult = FragmentFactory.CreateFragment<TableReplicateDistributionPolicy>()]

‎SqlScriptDom/Parser/TSql/TSql140.g‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25741,16 +25741,24 @@ tableHashDistributionPolicy returns [TableHashDistributionPolicy vResult = Fragm
2574125741
Identifier vIdentifier;
2574225742
}
2574325743
:
25744-
tHash:Identifier LeftParenthesis vIdentifier = identifier
25745-
{
25746-
Match(tHash, CodeGenerationSupporter.Hash);
25747-
vResult.DistributionColumn = vIdentifier;
25748-
UpdateTokenInfo(vResult, tHash);
25749-
}
25750-
tRParen:RightParenthesis
25751-
{
25752-
UpdateTokenInfo(vResult, tRParen);
25753-
}
25744+
tHash:Identifier
25745+
{
25746+
Match(tHash, CodeGenerationSupporter.Hash);
25747+
UpdateTokenInfo(vResult, tHash);
25748+
}
25749+
LeftParenthesis vIdentifier = identifier
25750+
{
25751+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
25752+
}
25753+
(Comma vIdentifier = identifier
25754+
{
25755+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
25756+
}
25757+
)*
25758+
tRParen:RightParenthesis
25759+
{
25760+
UpdateTokenInfo(vResult, tRParen);
25761+
}
2575425762
;
2575525763

2575625764
tableReplicateDistributionPolicy returns [TableReplicateDistributionPolicy vResult = FragmentFactory.CreateFragment<TableReplicateDistributionPolicy>()]

‎SqlScriptDom/Parser/TSql/TSql150.g‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26572,12 +26572,20 @@ tableHashDistributionPolicy returns [TableHashDistributionPolicy vResult = Fragm
2657226572
Identifier vIdentifier;
2657326573
}
2657426574
:
26575-
tHash:Identifier LeftParenthesis vIdentifier = identifier
26575+
tHash:Identifier
2657626576
{
2657726577
Match(tHash, CodeGenerationSupporter.Hash);
26578-
vResult.DistributionColumn = vIdentifier;
2657926578
UpdateTokenInfo(vResult, tHash);
2658026579
}
26580+
LeftParenthesis vIdentifier = identifier
26581+
{
26582+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
26583+
}
26584+
(Comma vIdentifier = identifier
26585+
{
26586+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
26587+
}
26588+
)*
2658126589
tRParen:RightParenthesis
2658226590
{
2658326591
UpdateTokenInfo(vResult, tRParen);

‎SqlScriptDom/Parser/TSql/TSql160.g‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26802,12 +26802,20 @@ tableHashDistributionPolicy returns [TableHashDistributionPolicy vResult = Fragm
2680226802
Identifier vIdentifier;
2680326803
}
2680426804
:
26805-
tHash:Identifier LeftParenthesis vIdentifier = identifier
26805+
tHash:Identifier
2680626806
{
2680726807
Match(tHash, CodeGenerationSupporter.Hash);
26808-
vResult.DistributionColumn = vIdentifier;
2680926808
UpdateTokenInfo(vResult, tHash);
2681026809
}
26810+
LeftParenthesis vIdentifier = identifier
26811+
{
26812+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
26813+
}
26814+
(Comma vIdentifier = identifier
26815+
{
26816+
AddAndUpdateTokenInfo(vResult, vResult.DistributionColumns, vIdentifier);
26817+
}
26818+
)*
2681126819
tRParen:RightParenthesis
2681226820
{
2681326821
UpdateTokenInfo(vResult, tRParen);

‎SqlScriptDom/ScriptDom/SqlServer/ScriptGenerator/SqlScriptGeneratorVisitor.TableHashDistributionPolicy.cs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ public override void ExplicitVisit(TableHashDistributionPolicy node)
1313
{
1414
GenerateIdentifier(CodeGenerationSupporter.Hash);
1515
GenerateSymbol(TSqlTokenType.LeftParenthesis);
16-
GenerateFragmentIfNotNull(node.DistributionColumn);
16+
17+
if (node.DistributionColumns?.Count > 0)
18+
{
19+
GenerateCommaSeparatedList(node.DistributionColumns);
20+
}
21+
1722
GenerateSymbol(TSqlTokenType.RightParenthesis);
1823
}
1924
}

‎Test/AssemblyTools/AssemblyTools.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<AssemblyName>SqlStudio.Tests.AssemblyTools</AssemblyName>
55
<RootNamespace>SqlStudio.Tests.AssemblyTools</RootNamespace>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<NoWarn>1591</NoWarn>
78
</PropertyGroup>
89
<ItemGroup>
910
<PackageReference Include="Microsoft.NET.Test.Sdk" />

‎Test/SqlDom/Baselines130/CreateTableTests130.sql‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,38 @@ CREATE TABLE [dbo].[table8] (
612612
[col2] INT NOT NULL
613613
);
614614

615+
616+
GO
617+
CREATE TABLE myTable1_HASH_MCD (
618+
id INT NOT NULL,
619+
lastName VARCHAR (20),
620+
zipCode VARCHAR (6)
621+
)
622+
WITH (DISTRIBUTION = HASH(id, lastName));
623+
624+
625+
GO
626+
CREATE TABLE myTable2_HEAP_HASH_MCD (
627+
id INT NOT NULL,
628+
lastName VARCHAR (20),
629+
zipCode VARCHAR (6)
630+
)
631+
WITH (DISTRIBUTION = HASH(id, lastName, zipCode), HEAP);
632+
633+
634+
GO
635+
CREATE TABLE myTable3_CI_HASH_MCD (
636+
id INT NOT NULL,
637+
lastName VARCHAR (20),
638+
zipCode VARCHAR (6)
639+
)
640+
WITH (DISTRIBUTION = HASH(id, lastName), CLUSTERED INDEX(zipCode));
641+
642+
643+
GO
644+
CREATE TABLE myTable4_CCI_HASH_MCD (
645+
[id] INT NOT NULL,
646+
[lastName] VARCHAR (20) NULL,
647+
[zipCode] VARCHAR (6) NULL
648+
)
649+
WITH (CLUSTERED COLUMNSTORE INDEX, DISTRIBUTION = HASH([id], [lastName], [zipCode]));

‎Test/SqlDom/Baselines140/CreateTableTests140.sql‎

Lines changed: 35 additions & 1 deletion

0 commit comments

Comments
 (0)