-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathSqlScriptGeneratorVisitor.CreateColumnStoreIndexStatement.cs
More file actions
65 lines (54 loc) · 2.52 KB
/
SqlScriptGeneratorVisitor.CreateColumnStoreIndexStatement.cs
File metadata and controls
65 lines (54 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//------------------------------------------------------------------------------
// <copyright file="SqlScriptGeneratorVisitor.CreateColumnStoreIndexStatement.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace Microsoft.SqlServer.TransactSql.ScriptDom.ScriptGenerator
{
partial class SqlScriptGeneratorVisitor
{
public override void ExplicitVisit(CreateColumnStoreIndexStatement node)
{
GenerateKeyword(TSqlTokenType.Create);
if (node.Clustered.HasValue)
{
GenerateSpaceAndKeyword(node.Clustered.Value ? TSqlTokenType.Clustered : TSqlTokenType.NonClustered);
}
GenerateSpaceAndIdentifier(CodeGenerationSupporter.ColumnStore);
GenerateSpaceAndKeyword(TSqlTokenType.Index);
// name
GenerateSpaceAndFragmentIfNotNull(node.Name);
NewLineAndIndent();
GenerateKeyword(TSqlTokenType.On);
GenerateSpaceAndFragmentIfNotNull(node.OnName);
// If clustered, ignore the columns, if any
if (!node.Clustered.GetValueOrDefault() &&
node.Columns != null && node.Columns.Count > 0)
{
GenerateParenthesisedCommaSeparatedList(node.Columns);
}
// Generate ordered columns if any, for both clustered and non-clustered indexes
// If node.Clustered is null or false, it indicates index type is non-clustered.
// If node.Clustered is true, it indicates index type is clustered.
if (node.OrderedColumns != null && node.OrderedColumns.Count > 0)
{
GenerateSpaceAndKeyword(TSqlTokenType.Order);
GenerateParenthesisedCommaSeparatedList(node.OrderedColumns);
}
if (node.FilterPredicate != null)
{
GenerateSpaceAndKeyword(TSqlTokenType.Where);
GenerateSpaceAndFragmentIfNotNull(node.FilterPredicate);
}
GenerateIndexOptions(node.IndexOptions);
if (node.OnFileGroupOrPartitionScheme != null)
{
NewLineAndIndent();
GenerateKeyword(TSqlTokenType.On);
GenerateSpaceAndFragmentIfNotNull(node.OnFileGroupOrPartitionScheme);
}
}
}
}