Class MssqlQueryProvider

Namespace: redb.MSSql.Query
Assembly: redb.MSSql.dll

PVT-backed terminal aggregations for free MSSql. Generates the
aggregate SQL via the server-side compiler dbo.pvt_build_aggregate_sql
(free PVT v2 module) and executes the produced statement client-side,
wrapping the single result row with FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
to materialize in one round-trip after the
build step.
Mirrors PostgresQueryProvider.Aggregation.cs — the goal is to keep
every aggregation request expressible as facet/aggregations JSON that
non-.NET clients can submit directly (e.g. a Python service composing a
facet AST and dispatching it through the SQL dialect's UDF).
Overrides the FilterExpression-typed virtual methods on the base provider.
Legacy facet-JSON overloads are also overridden because the MSSql
dialect's Query_AggregateField/Batch functions throw — we route
every aggregate path through the v2-pvt compiler instead.

public class MssqlQueryProvider : QueryProviderBase, IRedbQueryProvider

Inheritance

Object→QueryProviderBase→MssqlQueryProvider

Implements

Derived

Inherited Members

QueryProviderBase.BuildPvtInnerSqlAsync<TProps>(QueryContext<TProps>, bool, CancellationToken),QueryProviderBase.CanUsePvtPipeline<TProps>(QueryContext<TProps>),QueryProviderBase.CanUsePvtProjection<TProps>(QueryContext<TProps>),QueryProviderBase.CheckProOnlyDistinctFeatures<TProps>(QueryContext<TProps>),QueryProviderBase.CompilesNotTrue,QueryProviderBase.CreateFacetBuilder(),QueryProviderBase.CreateFilterParser(),QueryProviderBase.CreateOrderingParser(),QueryProviderBase.CreateQuery<TProps>(long, long?, bool),QueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, FilterExpression?),QueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, FilterExpression?, CancellationToken),QueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, string?),QueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, string?, CancellationToken),QueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, FilterExpression?),QueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, FilterExpression?, CancellationToken),QueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, string?),QueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, string?, CancellationToken),QueryProviderBase.ExecuteAnyAsync<TProps>(QueryContext<TProps>, CancellationToken),QueryProviderBase.ExecuteArrayGroupedAggregateAsync(long, string, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?),QueryProviderBase.ExecuteArrayGroupQueryAsync(ArrayGroupQuery, CancellationToken),QueryProviderBase.ExecuteAsync(Expression, Type),QueryProviderBase.ExecuteAsync(Expression, Type, CancellationToken),QueryProviderBase.ExecuteCountAsyncPvt<TProps>(QueryContext<TProps>, CancellationToken),QueryProviderBase.ExecuteCountAsync<TProps>(QueryContext<TProps>),QueryProviderBase.ExecuteCountAsync<TProps>(QueryContext<TProps>, CancellationToken),QueryProviderBase.ExecuteDeleteAsync(long, FilterExpression?),QueryProviderBase.ExecuteDeleteAsync(long, FilterExpression?, CancellationToken),QueryProviderBase.ExecuteDeleteAsync(long, string?),QueryProviderBase.ExecuteDeleteAsync(long, string?, CancellationToken),QueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?),QueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?, string?, CancellationToken),QueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?),QueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, string?, CancellationToken),QueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?),QueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, CancellationToken),QueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?),QueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, CancellationToken),QueryProviderBase.ExecuteToListAsyncPvtProjection<TProps>(QueryContext<TProps>, CancellationToken),QueryProviderBase.ExecuteToListAsyncPvt<TProps>(QueryContext<TProps>, Type, CancellationToken),QueryProviderBase.ExecuteToListAsync<TProps>(QueryContext<TProps>, Type),QueryProviderBase.ExecuteToListAsync<TProps>(QueryContext<TProps>, Type, CancellationToken),QueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, int?, int?),QueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, int?, int?, CancellationToken),QueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?),QueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?, CancellationToken),QueryProviderBase.GetAggregateSqlPreviewAsync<TProps, TResult>(QueryContext<TProps>, Expression<Func<RedbObject<TProps>, TResult>>),QueryProviderBase.GetAggregateSqlPreviewAsync<TProps, TResult>(QueryContext<TProps>, Expression<Func<RedbObject<TProps>, TResult>>, CancellationToken),QueryProviderBase.GetArrayGroupQuerySqlAsync(ArrayGroupQuery, CancellationToken),QueryProviderBase.GetFilterJsonAsync<TProps>(QueryContext<TProps>),QueryProviderBase.GetFilterJsonAsync<TProps>(QueryContext<TProps>, CancellationToken),QueryProviderBase.GetGroupBySqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?, string?, CancellationToken),QueryProviderBase.GetGroupBySqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, string?, CancellationToken),QueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?),QueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, CancellationToken),QueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?),QueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, CancellationToken),QueryProviderBase.GetSchemeAsync(long),QueryProviderBase.GetSchemeAsync(long, CancellationToken),QueryProviderBase.GetSqlPreviewAsyncPvt<TProps>(QueryContext<TProps>, CancellationToken),QueryProviderBase.GetSqlPreviewAsync<TProps>(QueryContext<TProps>),QueryProviderBase.GetSqlPreviewAsync<TProps>(QueryContext<TProps>, CancellationToken),QueryProviderBase.GetWindowSqlPreviewAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, int?, int?, CancellationToken),QueryProviderBase.GetWindowSqlPreviewAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?),QueryProviderBase.GetWindowSqlPreviewAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?, CancellationToken),QueryProviderBase.ParseAggregateExpressionForPreview<TProps, TResult>(Expression<Func<RedbObject<TProps>, TResult>>),QueryProviderBase.ShouldUseLazyLoading<TProps>(QueryContext<TProps>),QueryProviderBase.SortsByPropsLikeLinq

Methods

CreateFilterParser()

Creates MSSQL-specific filter expression parser.

protected override IFilterExpressionParser CreateFilterParser()

ExecuteAggregateAsync(long, string, AggregateFunction, FilterExpression?, CancellationToken)

Single-aggregate path. Delegates to ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, FilterExpression?)

public override Task<decimal?> ExecuteAggregateAsync(long schemeId, string fieldPath, AggregateFunction function, FilterExpression? filter, CancellationToken cancellationToken = default)

ExecuteAggregateAsync(long, string, AggregateFunction, string?, CancellationToken)

Single-aggregate path for facet-JSON callers (legacy

public override Task<decimal?> ExecuteAggregateAsync(long schemeId, string fieldPath, AggregateFunction function, string? filterJson = null, CancellationToken cancellationToken = default)

ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, FilterExpression?, CancellationToken)

Batch aggregate path: builds aggregations JSON, asks

public override Task<AggregateResult> ExecuteAggregateBatchAsync(long schemeId, IEnumerable<AggregateRequest> requests, FilterExpression? filter, CancellationToken cancellationToken = default)

ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, string?, CancellationToken)

Batch aggregate path with pre-built facet-JSON filter. Same PVT pipeline

public override Task<AggregateResult> ExecuteAggregateBatchAsync(long schemeId, IEnumerable<AggregateRequest> requests, string? filterJson = null, CancellationToken cancellationToken = default)

ExecuteArrayGroupQueryAsync(ArrayGroupQuery, CancellationToken)

GroupByArray on the free SQL Server provider: dbo.pvt_build_array_groupby_sql of the module builds the

public override Task<JsonDocument> ExecuteArrayGroupQueryAsync(ArrayGroupQuery query, CancellationToken cancellationToken = default)

ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?, string?, CancellationToken)

Performs GroupBy aggregation with FilterExpression (Pro version).

public override Task<JsonDocument?> ExecuteGroupedAggregateAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, FilterExpression? filter, string? havingJson = null, CancellationToken cancellationToken = default)

ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, string?, CancellationToken)

Performs GroupBy aggregation via the aggregate_grouped SQL function

public override Task<JsonDocument?> ExecuteGroupedAggregateAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? filterJson = null, string? havingJson = null, CancellationToken cancellationToken = default)

ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, CancellationToken)

Execute GroupBy with Window Functions with FilterExpression.

public override Task<JsonDocument?> ExecuteGroupedWindowQueryAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, FilterExpression? filter, string? havingJson = null, CancellationToken cancellationToken = default)

ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, CancellationToken)

Execute GroupBy with Window Functions. A provider that supports it overrides this; one that does not refuses

public override Task<JsonDocument?> ExecuteGroupedWindowQueryAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? filterJson = null, string? havingJson = null, CancellationToken cancellationToken = default)

ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, int?, int?, CancellationToken)

Execute window query with FilterExpression (Pro version).

public override Task<JsonDocument?> ExecuteWindowQueryAsync(long schemeId, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, FilterExpression? filter, string? frameJson = null, int? take = null, int? skip = null, CancellationToken cancellationToken = default)

ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?, CancellationToken)

Execute query with window functions (SQL function query_with_window).

public override Task<JsonDocument?> ExecuteWindowQueryAsync(long schemeId, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? filterJson = null, string? frameJson = null, int? take = null, int? skip = null, CancellationToken cancellationToken = default)

GetArrayGroupQuerySqlAsync(ArrayGroupQuery, CancellationToken)

SQL of ; see there.

public override Task<string> GetArrayGroupQuerySqlAsync(ArrayGroupQuery query, CancellationToken cancellationToken = default)

GetGroupBySqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?, string?, CancellationToken)

FilterExpression overload of

public override Task<string> GetGroupBySqlPreviewAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, FilterExpression? filter, string? havingJson = null, CancellationToken cancellationToken = default)

GetGroupBySqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, string?, CancellationToken)

Returns the inner SELECT compiled by dbo.pvt_build_groupby_sql for

public override Task<string> GetGroupBySqlPreviewAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? filterJson, string? havingJson = null, CancellationToken cancellationToken = default)

GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, CancellationToken)

SQL preview for GroupBy + Window query with FilterExpression.

public override Task<string> GetGroupedWindowSqlPreviewAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, FilterExpression? filter, string? havingJson = null, CancellationToken cancellationToken = default)

GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, CancellationToken)

SQL preview for GroupBy + Window query. A provider that supports it overrides this; one that does not refuses

public override Task<string> GetGroupedWindowSqlPreviewAsync(long schemeId, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? filterJson = null, string? havingJson = null, CancellationToken cancellationToken = default)

GetWindowSqlPreviewAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?, CancellationToken)

SQL preview for window query.

public override Task<string> GetWindowSqlPreviewAsync(long schemeId, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? filterJson = null, string? frameJson = null, int? take = null, int? skip = null, CancellationToken cancellationToken = default)

Constructors