Adding node overlays to execution plans (#1451)

* Adding node overlays to execution plans

* Adding critical warnings and parallelism

* adding critical warning, badge type enum

* Renaming badge type class

* Adding explicit values to Badge Type
This commit is contained in:
Aasim Khan
2022-04-08 15:20:54 -07:00
committed by GitHub
parent 1ce3647565
commit 454e4a4671
7 changed files with 104 additions and 2 deletions

View File

@@ -74,6 +74,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts
public string[] Subtext { get; set; }
public List<ExecutionPlanNode> Children { get; set; }
public List<ExecutionPlanEdges> Edges { get; set; }
/// <summary>
/// Add badge icon to nodes like warnings and parallelism
/// </summary>
public List<Badge> Badges { get; set; }
}
public class ExecutionPlanGraphPropertyBase
@@ -161,4 +165,24 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts
/// </summary>
public string GraphFileType { get; set; }
}
public class Badge
{
/// <summary>
/// Type of the node overlay. This determines the icon that is displayed for it
/// </summary>
public BadgeType Type { get; set; }
/// <summary>
/// Text to display for the overlay tooltip
/// </summary>
public string Tooltip { get; set; }
}
public enum BadgeType
{
WARNING = 0,
CRITICALWARNING = 1,
PARALLELISM = 2
}
}

View File

@@ -46,11 +46,46 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan
Properties = GetProperties(currentNode.Properties),
Children = currentNode.Children.Select(x => ConvertShowPlanTreeToExecutionPlanTree(x)).ToList(),
Edges = currentNode.Edges.Select(x => ConvertShowPlanEdgeToExecutionPlanEdge(x)).ToList(),
Badges = GenerateNodeOverlay(currentNode),
Name = currentNode.DisplayName,
ElapsedTimeInMs = currentNode.ElapsedTimeInMs
};
}
public static List<Badge> GenerateNodeOverlay(Node currentNode)
{
List<Badge> overlays = new List<Badge>();
if (currentNode.HasWarnings)
{
if (currentNode.HasCriticalWarnings)
{
overlays.Add(new Badge
{
Type = BadgeType.CRITICALWARNING,
Tooltip = SR.WarningOverlayTooltip
});
}
else
{
overlays.Add(new Badge
{
Type = BadgeType.WARNING,
Tooltip = SR.WarningOverlayTooltip
});
}
}
if (currentNode.IsParallel)
{
overlays.Add(new Badge
{
Type = BadgeType.PARALLELISM,
Tooltip = SR.ParallelismOverlayTooltip
});
}
return overlays;
}
public static ExecutionPlanEdges ConvertShowPlanEdgeToExecutionPlanEdge(Edge edge)
{
return new ExecutionPlanEdges

View File

@@ -161,7 +161,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
/// <summary>
/// Gets the value that indicates whether the Node has critical warnings.
/// </summary>
private bool HasCriticalWarnings
public bool HasCriticalWarnings
{
get
{