Skip to content

Commit 0517167

Browse files
author
Kusto Build System
committed
Auto-sync from Azure-Kusto-Service
1 parent 93d19e9 commit 0517167

7 files changed

Lines changed: 420 additions & 7 deletions

File tree

src/Kusto.Language/Binder/Binder_NodeBinder.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4093,6 +4093,48 @@ public override SemanticInfo VisitGraphMarkComponentsOperator(GraphMarkComponent
40934093
}
40944094
}
40954095

4096+
public override SemanticInfo VisitGraphWhereNodesOperator(GraphWhereNodesOperator node)
4097+
{
4098+
var diagnostics = s_diagnosticListPool.AllocateFromPool();
4099+
try
4100+
{
4101+
CheckNotFirstInPipe(node, diagnostics);
4102+
_binder.CheckIsExactType(node.Condition, ScalarTypes.Bool, diagnostics);
4103+
4104+
// get existing graph symbol from left-side of parent pipe operator
4105+
var graphSymbol = (node.Parent as PipeExpression)?.Expression?.ResultType is GraphSymbol g
4106+
? new GraphSymbol(g.EdgeShape, g.NodeShape)
4107+
: new GraphSymbol(this.RowScopeOrEmpty);
4108+
4109+
return new SemanticInfo(graphSymbol, diagnostics);
4110+
}
4111+
finally
4112+
{
4113+
s_diagnosticListPool.ReturnToPool(diagnostics);
4114+
}
4115+
}
4116+
4117+
public override SemanticInfo VisitGraphWhereEdgesOperator(GraphWhereEdgesOperator node)
4118+
{
4119+
var diagnostics = s_diagnosticListPool.AllocateFromPool();
4120+
try
4121+
{
4122+
CheckNotFirstInPipe(node, diagnostics);
4123+
_binder.CheckIsExactType(node.Condition, ScalarTypes.Bool, diagnostics);
4124+
4125+
// get existing graph symbol from left-side of parent pipe operator
4126+
var graphSymbol = (node.Parent as PipeExpression)?.Expression?.ResultType is GraphSymbol g
4127+
? new GraphSymbol(g.EdgeShape, g.NodeShape)
4128+
: new GraphSymbol(this.RowScopeOrEmpty);
4129+
4130+
return new SemanticInfo(graphSymbol, diagnostics);
4131+
}
4132+
finally
4133+
{
4134+
s_diagnosticListPool.ReturnToPool(diagnostics);
4135+
}
4136+
}
4137+
40964138
public override SemanticInfo VisitGraphToTableOperator(GraphToTableOperator node)
40974139
{
40984140
var diagnostics = s_diagnosticListPool.AllocateFromPool();
@@ -4557,6 +4599,11 @@ public override SemanticInfo VisitDirective(Directive node)
45574599
s_diagnosticListPool.ReturnToPool(diagnostics);
45584600
}
45594601
}
4602+
4603+
public override SemanticInfo VisitRestrictStatementWithClause(RestrictStatementWithClause node)
4604+
{
4605+
return null;
4606+
}
45604607
#endregion
45614608
}
45624609
}

src/Kusto.Language/Parser/QueryGrammar.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,6 +2915,24 @@ Parser<LexicalToken, DataScopeClause> DataScopeClause(CompletionKind ckind) =>
29152915
)
29162916
.WithTag("<graph-mark-components>");
29172917

2918+
var GraphWhereNodesOperator =
2919+
Rule(
2920+
Token(SyntaxKind.GraphWhereNodesKeyword, CompletionKind.QueryPrefix),
2921+
Required(Expression, CreateMissingExpression),
2922+
(graphWhereNodesKeyword, expression) =>
2923+
(QueryOperator)new GraphWhereNodesOperator(graphWhereNodesKeyword, expression)
2924+
)
2925+
.WithTag("<graph-where-nodes>");
2926+
2927+
var GraphWhereEdgesOperator =
2928+
Rule(
2929+
Token(SyntaxKind.GraphWhereEdgesKeyword, CompletionKind.QueryPrefix),
2930+
Required(Expression, CreateMissingExpression),
2931+
(graphWhereEdgesKeyword, expression) =>
2932+
(QueryOperator)new GraphWhereEdgesOperator(graphWhereEdgesKeyword, expression)
2933+
)
2934+
.WithTag("<graph-where-edges>");
2935+
29182936
var GraphToTableAsClause =
29192937
Rule(
29202938
Token(SyntaxKind.AsKeyword, CompletionKind.Keyword, CompletionPriority.Low),
@@ -3077,6 +3095,9 @@ Parser<LexicalToken, DataScopeClause> DataScopeClause(CompletionKind ckind) =>
30773095
GraphMatchOperator,
30783096
GraphShortestPathsOperator,
30793097
GraphMarkComponentsOperator,
3098+
// currently hidden until we document this feature.
3099+
GraphWhereNodesOperator.Hide(),
3100+
GraphWhereEdgesOperator.Hide(),
30803101
GraphToTableOperator,
30813102
InvokeOperator,
30823103
JoinOperator,
@@ -3352,6 +3373,15 @@ Parser<LexicalToken, DataScopeClause> DataScopeClause(CompletionKind ckind) =>
33523373
SimpleNameReference)
33533374
.WithCompletionHint(CompletionHint.Table | CompletionHint.MaterializedView | CompletionHint.ExternalTable | CompletionHint.GraphModel);
33543375

3376+
var RestrictStatementWithClause =
3377+
Rule(
3378+
Token(SyntaxKind.WithKeyword),
3379+
RequiredToken(SyntaxKind.OpenParenToken),
3380+
QueryParameterCommaList(QueryOperatorParameters.RestrictStatementParameters),
3381+
RequiredToken(SyntaxKind.CloseParenToken),
3382+
(withKeyword, openParen, properties, closeParen) =>
3383+
new RestrictStatementWithClause(withKeyword, openParen, properties, closeParen));
3384+
33553385
var RestrictStatement =
33563386
Rule(
33573387
Token(SyntaxKind.RestrictKeyword, CompletionKind.QueryPrefix).Hide(),
@@ -3360,8 +3390,9 @@ Parser<LexicalToken, DataScopeClause> DataScopeClause(CompletionKind ckind) =>
33603390
RequiredToken(SyntaxKind.OpenParenToken),
33613391
CommaList<Expression>(Restriction, CreateMissingExpression, oneOrMore: true),
33623392
RequiredToken(SyntaxKind.CloseParenToken),
3363-
(restrictKeyword, accessKeyword, toKeyword, openParen, list, closeParen) =>
3364-
(Statement)new RestrictStatement(restrictKeyword, accessKeyword, toKeyword, openParen, list, closeParen))
3393+
Optional(RestrictStatementWithClause),
3394+
(restrictKeyword, accessKeyword, toKeyword, openParen, list, closeParen, withProperties) =>
3395+
(Statement)new RestrictStatement(restrictKeyword, accessKeyword, toKeyword, openParen, list, closeParen, withProperties))
33653396
.WithTag("<restrict>");
33663397

33673398
var PatternPathValue =

src/Kusto.Language/Parser/QueryParser.cs

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6021,6 +6021,32 @@ private GraphMarkComponentsOperator ParseGraphMarkComponentsOperator()
60216021
}
60226022
#endregion
60236023

6024+
#region GraphWhereNodesOperator
6025+
private GraphWhereNodesOperator ParseGraphWhereNodesOperator()
6026+
{
6027+
if (ParseToken(SyntaxKind.GraphWhereNodesKeyword) is SyntaxToken keyword)
6028+
{
6029+
var expression = ParseUnnamedExpression() ?? CreateMissingExpression();
6030+
return new GraphWhereNodesOperator(keyword, expression);
6031+
}
6032+
6033+
return null;
6034+
}
6035+
#endregion
6036+
6037+
#region GraphWhereEdgesOperator
6038+
private GraphWhereEdgesOperator ParseGraphWhereEdgesOperator()
6039+
{
6040+
if (ParseToken(SyntaxKind.GraphWhereEdgesKeyword) is SyntaxToken keyword)
6041+
{
6042+
var expression = ParseUnnamedExpression() ?? CreateMissingExpression();
6043+
return new GraphWhereEdgesOperator(keyword, expression);
6044+
}
6045+
6046+
return null;
6047+
}
6048+
#endregion
6049+
60246050
#endregion
60256051

60266052
#region Query Expressions
@@ -6162,6 +6188,10 @@ private QueryOperator ParsePipedQueryOperator()
61626188
return ParseGraphToTableOperator();
61636189
case SyntaxKind.GraphMarkComponentsKeyword:
61646190
return ParseGraphMarkComponentsOperator();
6191+
case SyntaxKind.GraphWhereNodesKeyword:
6192+
return ParseGraphWhereNodesOperator();
6193+
case SyntaxKind.GraphWhereEdgesKeyword:
6194+
return ParseGraphWhereEdgesOperator();
61656195
case SyntaxKind.AssertSchemaKeyword:
61666196
return ParseAssertSchemaOperator();
61676197
default:
@@ -6650,7 +6680,6 @@ private QueryParametersStatement ParseQueryParametersStatement()
66506680
#endregion
66516681

66526682
#region restrict
6653-
66546683
private static readonly IReadOnlyList<Func<QueryParser, Expression>> ParseRestrictExpressionParsers =
66556684
new[]
66566685
{
@@ -6676,12 +6705,39 @@ private RestrictStatement ParseRestrictStatement()
66766705
var open = ParseRequiredToken(SyntaxKind.OpenParenToken);
66776706
var expressions = ParseCommaList(FnParseRestrictExpression, CreateMissingExpression, FnScanCommonListEnd, oneOrMore: true);
66786707
var close = ParseRequiredToken(SyntaxKind.CloseParenToken);
6679-
return new RestrictStatement(keyword, accessKeyword, toKeyword, open, expressions, close);
6708+
var withClause = ParseRestrictStatementWithClause();
6709+
return new RestrictStatement(keyword, accessKeyword, toKeyword, open, expressions, close, withClause);
6710+
}
6711+
6712+
return null;
6713+
}
6714+
6715+
private RestrictStatementWithClause ParseRestrictStatementWithClause()
6716+
{
6717+
var keyword = ParseToken(SyntaxKind.WithKeyword);
6718+
if (keyword != null)
6719+
{
6720+
var open = ParseRequiredToken(SyntaxKind.OpenParenToken);
6721+
var props = ParseCommaList(parser => parser.ParseRestrictProperty(), CreateMissingNamedParameter, FnScanCommonListEnd);
6722+
var close = ParseRequiredToken(SyntaxKind.CloseParenToken);
6723+
return new RestrictStatementWithClause(keyword, open, props, close);
66806724
}
66816725

66826726
return null;
66836727
}
66846728

6729+
private NamedParameter ParseRestrictProperty()
6730+
{
6731+
var name = ParseRenameNameDeclaration();
6732+
if (name != null)
6733+
{
6734+
var equal = ParseRequiredToken(SyntaxKind.EqualToken);
6735+
var value = ParseExternalDataPropertyValue() ?? CreateMissingValue();
6736+
return new NamedParameter(name, equal, value);
6737+
}
6738+
6739+
return null;
6740+
}
66856741
#endregion
66866742

66876743
#region declare pattern

src/Kusto.Language/QueryOperatorParameters.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public static class QueryOperatorParameters
112112
public static readonly QueryOperatorParameter ShortestPathsOutputs =
113113
new QueryOperatorParameter("output", QueryOperatorParameterValueKind.Word, values: KustoFacts.ShortestPathsOutputs);
114114

115+
public static readonly QueryOperatorParameter ManagedIdentityAuthEnabled =
116+
new QueryOperatorParameter("AllowManagedIdentityAuthentication", QueryOperatorParameterValueKind.BoolLiteral, isRepeatable: false);
117+
115118
/// <summary>
116119
/// All query operator parameters.
117120
/// Does not include parameters used for other syntax clauses (like render with properties)
@@ -210,6 +213,11 @@ public static class QueryOperatorParameters
210213
Output.WithValues(KustoFacts.ShortestPathsOutputs),
211214
}.ToReadOnly();
212215

216+
public static readonly IReadOnlyList<QueryOperatorParameter> RestrictStatementParameters = new QueryOperatorParameter[]
217+
{
218+
ManagedIdentityAuthEnabled
219+
}.ToReadOnly();
220+
213221

214222
public static readonly IReadOnlyList<QueryOperatorParameter> JoinParameters = new QueryOperatorParameter[]
215223
{

0 commit comments

Comments
 (0)