Path: redb/redb.Core/Query/Base/QueryProviderBase.GroupedWindow.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Query/Base/QueryProviderBase.GroupedWindow.cs
----
using System.Text.Json;
using Microsoft.Extensions.Logging;
using redb.Core.Query.Aggregation;
using redb.Core.Query.Grouping;
using redb.Core.Query.QueryExpressions;
using redb.Core.Query.Window;
namespace redb.Core.Query.Base;
///
/// QueryProviderBase: GroupBy + Window Functions
///
public abstract partial class QueryProviderBase
{
///
/// Execute GroupBy with Window Functions. A provider that supports it overrides this; one that does not refuses
/// with its own name.
///
public virtual Task ExecuteGroupedWindowQueryAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
string? filterJson = null,
string? havingJson = null, CancellationToken cancellationToken = default)
=> throw new NotSupportedException($"GroupBy + WithWindow is not supported by {GetType().Name}.");
///
/// Execute GroupBy with Window Functions with FilterExpression.
/// Free fallback: converts FilterExpression to facet-JSON.
///
public virtual Task ExecuteGroupedWindowQueryAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
FilterExpression? filter,
string? havingJson = null, CancellationToken cancellationToken = default)
{
var filterJson = filter != null ? _facetBuilder.BuildFacetFilters(filter) : null;
return ExecuteGroupedWindowQueryAsync(schemeId, groupFields, aggregations, windowFuncs, partitionBy, orderBy, filterJson, havingJson, cancellationToken);
}
///
/// SQL preview for GroupBy + Window query. A provider that supports it overrides this; one that does not refuses
/// with its own name.
///
public virtual Task GetGroupedWindowSqlPreviewAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
string? filterJson = null,
string? havingJson = null, CancellationToken cancellationToken = default)
=> throw new NotSupportedException($"GroupBy + WithWindow is not supported by {GetType().Name}.");
///
/// SQL preview for GroupBy + Window query with FilterExpression.
/// Free fallback: converts FilterExpression to facet-JSON.
///
public virtual Task GetGroupedWindowSqlPreviewAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
FilterExpression? filter,
string? havingJson = null, CancellationToken cancellationToken = default)
{
var filterJson = filter != null ? _facetBuilder.BuildFacetFilters(filter) : null;
return GetGroupedWindowSqlPreviewAsync(schemeId, groupFields, aggregations, windowFuncs, partitionBy, orderBy, filterJson, havingJson, cancellationToken);
}
///
/// SQL preview of a GroupBy. A provider that supports it overrides this; one that does not refuses with its own name.
///
public virtual Task GetGroupBySqlPreviewAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
string? filterJson,
string? havingJson = null, CancellationToken cancellationToken = default)
=> throw new NotSupportedException($"GroupBy SQL preview is not supported by {GetType().Name}.");
///
/// SQL preview of a GroupBy with FilterExpression. Free fallback: converts FilterExpression to facet-JSON.
///
public virtual Task GetGroupBySqlPreviewAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
FilterExpression? filter,
string? havingJson = null, CancellationToken cancellationToken = default)
{
var filterJson = filter != null ? _facetBuilder.BuildFacetFilters(filter) : null;
return GetGroupBySqlPreviewAsync(schemeId, groupFields, aggregations, filterJson, havingJson, cancellationToken);
}
}