Skip to content

Commit

Permalink
Auto-sync from Azure-Kusto-Service
Browse files Browse the repository at this point in the history
  • Loading branch information
Kusto Build System committed Nov 14, 2024
1 parent 68121a2 commit e6ecbb6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 11 deletions.
14 changes: 13 additions & 1 deletion src/Kusto.Language/Binder/Binder_ContextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,19 @@ public override void VisitGraphMatchOperator(GraphMatchOperator node)
|| (node.ProjectClause != null && _position >= node.ProjectClause.TextStart))
{
_binder._localScope = new LocalScope(_binder._localScope);
_binder.AddGraphMatchPatternDeclarationsToLocalScope(node);
_binder.AddGraphMatchPatternDeclarationsToLocalScope(node.Patterns);
}
}

public override void VisitGraphShortestPathsOperator(GraphShortestPathsOperator node)
{
base.VisitGraphShortestPathsOperator(node);

if ((node.WhereClause != null && _position >= node.WhereClause.TextStart)
|| (node.ProjectClause != null && _position >= node.ProjectClause.TextStart))
{
_binder._localScope = new LocalScope(_binder._localScope);
_binder.AddGraphMatchPatternDeclarationsToLocalScope(node.Patterns);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/Kusto.Language/Binder/Binder_Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,13 @@ private void AddStepDeclarationsToLocalScope(ScanOperator node)
}
}

private void BindGraphMatchPatternDeclarations(GraphMatchOperator graphMatch)
private void BindGraphMatchPatternDeclarations(SyntaxNode operatorNode, SyntaxList<SeparatedElement<GraphMatchPattern>> patterns)
{
var graphScope = GetGraphSymbol(graphMatch);
var graphScope = GetGraphSymbol(operatorNode);
var edgeTuple = graphScope != null ? new TupleSymbol(graphScope.EdgeShape.Columns, graphScope.EdgeShape) : TupleSymbol.Empty;
var nodeTuple = graphScope?.NodeShape != null ? new TupleSymbol(graphScope.NodeShape.Columns, graphScope.NodeShape) : TupleSymbol.Empty;

foreach (var pattern in graphMatch.Patterns)
foreach (var pattern in patterns)
{
foreach (var notation in pattern.Element.PatternElements)
{
Expand Down Expand Up @@ -615,9 +615,9 @@ private VariableSymbol CreateGraphMatchEdgeVariableSymbol(GraphMatchPatternEdge
return new VariableSymbol(edge.Name.SimpleName, new TupleSymbol(newColumns));
}

private void AddGraphMatchPatternDeclarationsToLocalScope(GraphMatchOperator graphMatch)
private void AddGraphMatchPatternDeclarationsToLocalScope(SyntaxList<SeparatedElement<GraphMatchPattern>> patterns)
{
foreach (var pattern in graphMatch.Patterns)
foreach (var pattern in patterns)
{
foreach (var notation in pattern.Element.PatternElements)
{
Expand Down
16 changes: 14 additions & 2 deletions src/Kusto.Language/Binder/Binder_NodeBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3911,8 +3911,20 @@ public override SemanticInfo VisitGraphMarkComponentsOperator(GraphMarkComponent
_binder.CheckQueryOperatorParameters(node.Parameters, QueryOperatorParameters.GraphMarkComponentsParameters, diagnostics);
}

var symbol = new GraphSymbol(this.RowScopeOrEmpty);
return new SemanticInfo(symbol, diagnostics);
// get existing graph symbol from left-side of parent pipe operator
var graphSymbol = (node.Parent as PipeExpression)?.Expression?.ResultType is GraphSymbol g
? new GraphSymbol(g.EdgeShape, g.NodeShape)
: new GraphSymbol(this.RowScopeOrEmpty);

// add component-id column to node shape
var componentIdName = node.Parameters.GetParameterNameValue(QueryOperatorParameters.WithComponentId) as string ?? "ComponentId";
var componentIdColumn = new ColumnSymbol(componentIdName, ScalarTypes.Long);
var newNodeShape = graphSymbol.NodeShape != null
? graphSymbol.NodeShape.AddColumns(componentIdColumn)
: new TableSymbol(new[] { componentIdColumn });
graphSymbol = graphSymbol.WithNodeShape(newNodeShape);

return new SemanticInfo(graphSymbol, diagnostics);
}
finally
{
Expand Down
31 changes: 29 additions & 2 deletions src/Kusto.Language/Binder/Binder_TreeBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,35 @@ public override void VisitGraphMatchOperator(GraphMatchOperator node)
_binder._localScope = new LocalScope(oldLocalScope);
try
{
_binder.BindGraphMatchPatternDeclarations(node);
_binder.AddGraphMatchPatternDeclarationsToLocalScope(node);
node.Parameters.Accept(this);

_binder.BindGraphMatchPatternDeclarations(node, node.Patterns);
_binder.AddGraphMatchPatternDeclarationsToLocalScope(node.Patterns);

node.WhereClause?.Accept(this);
node.ProjectClause?.Accept(this);
}
finally
{
_binder._rowScope = oldScope;
_binder._localScope = oldLocalScope;
}

BindNode(node);
}

public override void VisitGraphShortestPathsOperator(GraphShortestPathsOperator node)
{
var oldScope = _binder._rowScope;
var oldLocalScope = _binder._localScope;
_binder._rowScope = null;
_binder._localScope = new LocalScope(oldLocalScope);
try
{
node.Parameters.Accept(this);

_binder.BindGraphMatchPatternDeclarations(node, node.Patterns);
_binder.AddGraphMatchPatternDeclarationsToLocalScope(node.Patterns);

node.WhereClause?.Accept(this);
node.ProjectClause?.Accept(this);
Expand Down
2 changes: 1 addition & 1 deletion src/Kusto.Language/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.7.1
11.7.2

0 comments on commit e6ecbb6

Please sign in to comment.