Class ProTreeQueryProvider

Assembly: redb.SQLite.Pro.dll

ProTreeQueryProvider - Aggregation for trees (partial).
CTE for tree traversal + aggregations.
DRY: Uses ProSqlBuilder for common operations.

public class ProTreeQueryProvider : SqliteTreeQueryProvider, ITreeQueryProvider, IRedbQueryProvider

Inheritance

Implements

Inherited Members

TreeQueryProviderBase.AsChildrenOfAncestors<TProps>(TreeQueryContext<TProps>, TreeFilter, IReadOnlyCollection<long>),TreeQueryProviderBase.AsDescendantsOfAncestors<TProps>(TreeQueryContext<TProps>, TreeFilter, IReadOnlyCollection<long>),TreeQueryProviderBase.AsDescendantsWithinDepthOfAncestors<TProps>(TreeQueryContext<TProps>, TreeFilter, IReadOnlyCollection<long>),TreeQueryProviderBase.BuildPvtDistinctOnJson<TProps>(QueryContext<TProps>),TreeQueryProviderBase.Cache,TreeQueryProviderBase.CheckProOnlyDistinctFeatures<TProps>(QueryContext<TProps>),TreeQueryProviderBase.ConvertToTreeObject<TProps>(RedbObject<TProps>),TreeQueryProviderBase.CreateFacetBuilder(),TreeQueryProviderBase.CreateFilterParser(),TreeQueryProviderBase.CreateOrderingParser(),TreeQueryProviderBase.CreateQueryProvider(),TreeQueryProviderBase.CreateQuery<TProps>(long, long?, bool),TreeQueryProviderBase.CreateTreeQueryable<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.CreateTreeQuery<TProps>(long, long?, bool, long?, int?),TreeQueryProviderBase.DeserializeTreeObjects<TProps>(string?),TreeQueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, FilterExpression?, CancellationToken),TreeQueryProviderBase.ExecuteAggregateAsync(long, string, AggregateFunction, string?, CancellationToken),TreeQueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, FilterExpression?, CancellationToken),TreeQueryProviderBase.ExecuteAggregateBatchAsync(long, IEnumerable<AggregateRequest>, string?, CancellationToken),TreeQueryProviderBase.ExecuteArrayGroupQueryAsync(ArrayGroupQuery, CancellationToken),TreeQueryProviderBase.ExecuteAsync(Expression, Type, CancellationToken),TreeQueryProviderBase.ExecuteDeleteAsync(long, FilterExpression?, CancellationToken),TreeQueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?, string?, CancellationToken),TreeQueryProviderBase.ExecuteGroupedAggregateAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, string?, CancellationToken),TreeQueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, CancellationToken),TreeQueryProviderBase.ExecuteGroupedWindowQueryAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, CancellationToken),TreeQueryProviderBase.ExecuteTreeAnyAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),TreeQueryProviderBase.ExecuteTreeArrayGroupQueryAsync<TProps>(TreeQueryContext<TProps>, ArrayGroupQuery, CancellationToken),TreeQueryProviderBase.ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),TreeQueryProviderBase.ExecuteTreeDeleteAsync(long[], CancellationToken),TreeQueryProviderBase.ExecuteTreeGroupedAggregateAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, CancellationToken),TreeQueryProviderBase.ExecuteTreeGroupedWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken),TreeQueryProviderBase.ExecuteTreeToListAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),TreeQueryProviderBase.ExecuteTreeWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken),TreeQueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, int?, int?, CancellationToken),TreeQueryProviderBase.ExecuteWindowQueryAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?, CancellationToken),TreeQueryProviderBase.ExistsResult(object?),TreeQueryProviderBase.FirstNodeProbe<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.GetArrayGroupQuerySqlAsync(ArrayGroupQuery, CancellationToken),TreeQueryProviderBase.GetFilterJsonAsync<TProps>(QueryContext<TProps>, CancellationToken),TreeQueryProviderBase.GetGroupBySqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, FilterExpression?, string?, CancellationToken),TreeQueryProviderBase.GetGroupBySqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, string?, CancellationToken),TreeQueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, FilterExpression?, string?, CancellationToken),TreeQueryProviderBase.GetGroupedWindowSqlPreviewAsync(long, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, CancellationToken),TreeQueryProviderBase.GetIdsWithAncestorsAsync<TProps>(List<long>, CancellationToken),TreeQueryProviderBase.GetOptimizableHasAncestorFilter<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.GetOptimizableHasDescendantFilter<TProps>(TreeQueryContext<TProps>),TreeQueryProviderBase.GetSchemeAsync(long, CancellationToken),TreeQueryProviderBase.GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),TreeQueryProviderBase.GetSqlPreviewAsync<TProps>(QueryContext<TProps>, CancellationToken),TreeQueryProviderBase.GetTreeArrayGroupQuerySqlAsync<TProps>(TreeQueryContext<TProps>, ArrayGroupQuery, CancellationToken),TreeQueryProviderBase.GetTreeGroupBySqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, CancellationToken),TreeQueryProviderBase.GetTreeGroupedWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken),TreeQueryProviderBase.GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken),TreeQueryProviderBase.GetWindowSqlPreviewAsync(long, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, string?, int?, int?, CancellationToken),TreeQueryProviderBase.LoadObjectsByIdsAsync(List<long>, int?, CancellationToken),TreeQueryProviderBase.LoadObjectsByIdsAsync<TProps>(List<long>, int?, CancellationToken),TreeQueryProviderBase.MapRowToTreeObject<TProps>(RedbObjectRow),TreeQueryProviderBase.UnresolvedTreeFilter(),SqliteTreeQueryProvider.CreateQueryProvider(),SqliteTreeQueryProvider.CreateTreeQueryable<TProps>(TreeQueryContext<TProps>),SqliteTreeQueryProvider.ExecuteTreeAnyAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),SqliteTreeQueryProvider.ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),SqliteTreeQueryProvider.ExecuteTreeToListAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),SqliteTreeQueryProvider.GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, CancellationToken),SqliteTreeQueryProvider.WithIdsInstead<TProps>(TreeQueryContext<TProps>, TreeFilter, IReadOnlyCollection<long>)

Methods

CreateFilterParser()

Pro: Uses ProFilterExpressionParser with arithmetic and function support

protected override ProFilterExpressionParser CreateFilterParser()

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

Execute aggregation on EAV field (SQL strategy for simple fields).

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

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

Execute batch aggregation (multiple fields in one query).

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

ExecuteArrayGroupQueryAsync(ArrayGroupQuery, CancellationToken)

Array grouping without a tree: the flat provider answers it.

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

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

Execute GroupBy aggregation. Uses filterJson for Free version compatibility.

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

ExecuteTreeAggregateAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<AggregateRequest>, CancellationToken)

Execute tree aggregation with CTE.

public Task<Dictionary<string, decimal?>> ExecuteTreeAggregateAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<AggregateRequest> aggregations, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeAnyAsync<TProps>(TreeQueryContext<TProps>, CancellationToken)

Pro Override: Tree Any as the list statement cut to one node (LIMIT 1, no ordering), the first column of

protected override Task<bool> ExecuteTreeAnyAsync<TProps>(TreeQueryContext<TProps> context, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeArrayGroupQueryAsync<TProps>(TreeQueryContext<TProps>, ArrayGroupQuery, CancellationToken)

Array grouping over the objects of a subtree. Base implementation: the ids of the subtree (roots, depth and

public override Task<JsonDocument> ExecuteTreeArrayGroupQueryAsync<TProps>(TreeQueryContext<TProps> context, ArrayGroupQuery query, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps>, CancellationToken)

Pro Override: Tree Count via CTE + PVT.

protected override Task<int> ExecuteTreeCountAsync<TProps>(TreeQueryContext<TProps> context, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeGroupByAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, CancellationToken)

Execute GROUP BY on tree with CTE.

public Task<string> ExecuteTreeGroupByAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeGroupedAggregateAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, CancellationToken)

ITreeQueryProvider implementation: Execute GROUP BY with tree context.

public override Task<JsonDocument?> ExecuteTreeGroupedAggregateAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? havingJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeGroupedWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken)

Execute Tree GroupBy + Window query.

public override Task<JsonDocument?> ExecuteTreeGroupedWindowQueryAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? havingJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeToListAsync<TProps>(TreeQueryContext<TProps>, CancellationToken)

Pro Override: Tree ToList via CTE + PVT.

protected override Task<object> ExecuteTreeToListAsync<TProps>(TreeQueryContext<TProps> context, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeWindowAsync<TProps>(TreeQueryContext<TProps>, string, string, string, string, string?, CancellationToken)

Execute Window Functions on tree with CTE (legacy JSON version).

public Task<string> ExecuteTreeWindowAsync<TProps>(TreeQueryContext<TProps> context, string selectFieldsJson, string windowFunctionsJson, string partitionByJson, string orderByJson, string? frameJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

ExecuteTreeWindowQueryAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken)

Execute Window Functions on tree with CTE (interface implementation).

public override Task<JsonDocument?> ExecuteTreeWindowQueryAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? frameJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

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 .

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

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

Returns SQL preview for GroupBy query with tree constraints.

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

GetSchemeAsync(long, CancellationToken)

Get scheme by ID (for projections) - delegate to base provider

public override Task<IRedbScheme?> GetSchemeAsync(long schemeId, CancellationToken cancellationToken = default)

GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, CancellationToken)

Pro: Tree SQL Preview (DRY - uses BuildTreeQuerySqlAsync)

public override Task<string> GetSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, CancellationToken cancellationToken = default) where TProps : class, new()

GetTreeAggregateSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<AggregateRequest>, CancellationToken)

SQL Preview for Tree Aggregate (DRY - same SQL as Execute)

public Task<string> GetTreeAggregateSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<AggregateRequest> aggregations, CancellationToken cancellationToken = default) where TProps : class, new()

GetTreeArrayGroupQuerySqlAsync<TProps>(TreeQueryContext<TProps>, ArrayGroupQuery, CancellationToken)

SQL of : the flat array grouping over the ids of the subtree.

public override Task<string> GetTreeArrayGroupQuerySqlAsync<TProps>(TreeQueryContext<TProps> context, ArrayGroupQuery query, CancellationToken cancellationToken = default) where TProps : class, new()

GetTreeGroupBySqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, string?, CancellationToken)

SQL Preview for Tree GroupBy (DRY - same SQL as Execute)

public override Task<string> GetTreeGroupBySqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, string? havingJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

GetTreeGroupedWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<GroupFieldRequest>, IEnumerable<AggregateRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken)

SQL preview for Tree GroupBy + Window.

public override Task<string> GetTreeGroupedWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<GroupFieldRequest> groupFields, IEnumerable<AggregateRequest> aggregations, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? havingJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowFuncRequest>, IEnumerable<WindowFieldRequest>, IEnumerable<WindowOrderRequest>, string?, CancellationToken)

SQL Preview for Tree Window (typed interface version).

public override Task<string> GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, IEnumerable<WindowFieldRequest> selectFields, IEnumerable<WindowFuncRequest> windowFuncs, IEnumerable<WindowFieldRequest> partitionBy, IEnumerable<WindowOrderRequest> orderBy, string? frameJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps>, string, string, string, string, string?, CancellationToken)

SQL Preview for Tree Window (DRY - same SQL as Execute)

public Task<string> GetTreeWindowSqlPreviewAsync<TProps>(TreeQueryContext<TProps> context, string selectFieldsJson, string windowFunctionsJson, string partitionByJson, string orderByJson, string? frameJson = null, CancellationToken cancellationToken = default) where TProps : class, new()

Constructors