Path: redb/redb.Core/Query/Base/QueryProviderBase.Window.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.Window.cs
----
using System.Text.Json;
using Microsoft.Extensions.Logging;
using redb.Core.Query.QueryExpressions;
using redb.Core.Query.Window;
namespace redb.Core.Query.Base;
///
/// QueryProviderBase: Window Functions
///
public abstract partial class QueryProviderBase
{
///
/// A query with window functions and a facet-JSON filter, built by the provider through its v2-pvt module. The
/// base asked the legacy query_with_window function, which no shipped dialect has.
///
public abstract Task ExecuteWindowQueryAsync(
long schemeId,
IEnumerable selectFields,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
string? filterJson = null,
string? frameJson = null,
int? take = null,
int? skip = null, CancellationToken cancellationToken = default);
///
/// SQL preview for window query.
/// Base implementation returns placeholder (overridden in Pro).
///
public virtual Task GetWindowSqlPreviewAsync(
long schemeId,
IEnumerable selectFields,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
string? filterJson = null,
string? frameJson = null,
int? take = null,
int? skip = null, CancellationToken cancellationToken = default)
{
// Base version uses SQL function, no direct SQL preview available
return Task.FromResult($"-- Window SQL Preview not available in Open Source version\n-- SchemeId: {schemeId}\n-- Use Pro version for SQL preview");
}
///
/// Execute window query with FilterExpression (Pro version).
/// Free fallback: converts FilterExpression to facet-JSON.
///
public virtual async Task ExecuteWindowQueryAsync(
long schemeId,
IEnumerable selectFields,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
FilterExpression? filter,
string? frameJson = null,
int? take = null,
int? skip = null, CancellationToken cancellationToken = default)
{
var filterJson = filter != null ? _facetBuilder.BuildFacetFilters(filter) : null;
return await ExecuteWindowQueryAsync(schemeId, selectFields, windowFuncs, partitionBy, orderBy, filterJson, frameJson, take, skip);
}
///
/// SQL preview for window query with FilterExpression (Pro version).
/// Free: converts FilterExpression to facet-JSON, as the execution does.
///
public virtual Task GetWindowSqlPreviewAsync(
long schemeId,
IEnumerable selectFields,
IEnumerable windowFuncs,
IEnumerable partitionBy,
IEnumerable orderBy,
FilterExpression? filter,
string? frameJson = null,
int? take = null,
int? skip = null, CancellationToken cancellationToken = default)
{
var filterJson = filter != null ? _facetBuilder.BuildFacetFilters(filter) : null;
return GetWindowSqlPreviewAsync(schemeId, selectFields, windowFuncs, partitionBy, orderBy, filterJson, frameJson, take, skip, cancellationToken);
}
}