Path: redb/redb.Core/Query/Base/QueryProviderBase.Grouping.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.Grouping.cs
----
using System.Text.Json;
using Microsoft.Extensions.Logging;
using redb.Core.Query.Aggregation;
using redb.Core.Query.Grouping;
using redb.Core.Query.QueryExpressions;
namespace redb.Core.Query.Base;
///
/// QueryProviderBase: GroupBy functionality
///
public abstract partial class QueryProviderBase
{
///
/// GroupBy aggregation with a facet-JSON filter, built by the provider through its v2-pvt module. The base asked
/// the legacy aggregate_grouped function, which no shipped dialect has.
///
public abstract Task ExecuteGroupedAggregateAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
string? filterJson = null,
string? havingJson = null, CancellationToken cancellationToken = default);
///
/// Performs GroupBy aggregation with FilterExpression (Pro version).
/// Free version fallback: converts FilterExpression to facet-JSON and calls the string-based method.
///
public virtual async Task ExecuteGroupedAggregateAsync(
long schemeId,
IEnumerable groupFields,
IEnumerable aggregations,
FilterExpression? filter,
string? havingJson = null, CancellationToken cancellationToken = default)
{
// Free version fallback: convert FilterExpression to facet-JSON
var filterJson = filter != null ? _facetBuilder.BuildFacetFilters(filter) : null;
return await ExecuteGroupedAggregateAsync(schemeId, groupFields, aggregations, filterJson, havingJson);
}
///
/// Grouping over the elements of an array. Every provider that supports GroupByArray overrides it; a provider
/// that does not refuses with its own name instead of answering with nothing.
///
public virtual Task ExecuteArrayGroupQueryAsync(
ArrayGroupQuery query, CancellationToken cancellationToken = default)
=> throw new NotSupportedException($"GroupByArray is not supported by {GetType().Name}.");
///
/// SQL of ; see there.
///
public virtual Task GetArrayGroupQuerySqlAsync(
ArrayGroupQuery query, CancellationToken cancellationToken = default)
=> throw new NotSupportedException($"GroupByArray is not supported by {GetType().Name}.");
}