mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-23 01:25:42 -05:00
Feat/result streaming (#721)
This changes adds the following two notifications from the results processing within a batch. These new notifications allows a consumer to stream results from a resultset instead of getting them all at once after the entire resultset has been fetched. ResultsAvailable This is issued after at least 1 row has been fetched for this resultset. ResultsUpdated This is issued periodically as more rows are available on this resultset. The final send of this notification when all rows have been fetched has the property 'Complete' set to true in the ResultSummary object. Detailed Change Log: * Initial completed implementation of QueryResults stream feature. 3 unittests still need fixing * Fix for the 3 failing test. I will look into making MockBehavior strict again for the three tests later * Making GetReader/GetWriter use filestream objects in FileShare.ReadWrite mode so the file can be concurrently read and written * Changing resultsAvailable also to fire off on a timer instead of after 1st row * adding a project for clr TableValuedFunction to produce result set with delays after each row. This is helpful in end to end testing. * Fixing up some tests and simplifying implementation of result update timer * Address review comments * Some test fixes * Disabled flaky test verification
This commit is contained in:
@@ -49,5 +49,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||
/// The special action of the batch
|
||||
/// </summary>
|
||||
public SpecialAction SpecialAction { get; set; }
|
||||
|
||||
public override string ToString() => $"Batch Id:'{Id}', Elapsed:'{ExecutionElapsed}', HasError:'{HasError}'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,61 @@ using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters to return when a result set is started or completed
|
||||
/// Base class of parameters to return when a result set is available, updated or completed
|
||||
/// </summary>
|
||||
public class ResultSetEventParams
|
||||
public abstract class ResultSetEventParams
|
||||
{
|
||||
public ResultSetSummary ResultSetSummary { get; set; }
|
||||
|
||||
public string OwnerUri { get; set; }
|
||||
}
|
||||
|
||||
public class ResultSetCompleteEvent
|
||||
/// <summary>
|
||||
/// Parameters to return when a result set is completed.
|
||||
/// </summary>
|
||||
public class ResultSetCompleteEventParams : ResultSetEventParams
|
||||
{
|
||||
public static readonly
|
||||
EventType<ResultSetEventParams> Type =
|
||||
EventType<ResultSetEventParams>.Create("query/resultSetComplete");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters to return when a result set is available.
|
||||
/// </summary>
|
||||
public class ResultSetAvailableEventParams : ResultSetEventParams
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters to return when a result set is updated
|
||||
/// </summary>
|
||||
public class ResultSetUpdatedEventParams : ResultSetEventParams
|
||||
{
|
||||
}
|
||||
|
||||
public class ResultSetCompleteEvent
|
||||
{
|
||||
public static string MethodName { get; } = "query/resultSetComplete";
|
||||
|
||||
public static readonly
|
||||
EventType<ResultSetCompleteEventParams> Type =
|
||||
EventType<ResultSetCompleteEventParams>.Create(MethodName);
|
||||
}
|
||||
|
||||
public class ResultSetAvailableEvent
|
||||
{
|
||||
public static string MethodName { get; } = "query/resultSetAvailable";
|
||||
|
||||
public static readonly
|
||||
EventType<ResultSetAvailableEventParams> Type =
|
||||
EventType<ResultSetAvailableEventParams>.Create(MethodName);
|
||||
}
|
||||
|
||||
public class ResultSetUpdatedEvent
|
||||
{
|
||||
public static string MethodName { get; } = "query/resultSetUpdated";
|
||||
|
||||
public static readonly
|
||||
EventType<ResultSetUpdatedEventParams> Type =
|
||||
EventType<ResultSetUpdatedEventParams>.Create(MethodName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,5 +51,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||
public ResultMessage()
|
||||
{
|
||||
}
|
||||
public override string ToString() => $"Message on Batch Id:'{BatchId}', IsError:'{IsError}', Message:'{Message}'";
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,15 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||
public int BatchId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of rows that was returned with the resultset
|
||||
/// The number of rows that are available for the resultset thus far
|
||||
/// </summary>
|
||||
public long RowCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true it indicates that all rows have been fetched and the RowCount being sent across is final for this ResultSet
|
||||
/// </summary>
|
||||
public bool Complete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Details about the columns that are provided as solutions
|
||||
/// </summary>
|
||||
@@ -35,5 +40,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||
/// </summary>
|
||||
public SpecialAction SpecialAction { get; set; }
|
||||
|
||||
public override string ToString() => $"Result Summary Id:{Id}, Batch Id:'{BatchId}', RowCount:'{RowCount}', Complete:'{Complete}', SpecialAction:'{SpecialAction}'";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user