Skip to content

RangeAgg and RangeIntersectAgg over a sequence of RangeSet (range_agg / range_intersect_agg on multiranges) #93

Closed

Description

@CaffeinatedCoder

PostgreSQL declares both aggregates twice: range_agg(anyrange) → anymultirange and range_agg(anymultirange) → anymultirange; range_intersect_agg(anyrange) → anyrange and range_intersect_agg(anymultirange) → anymultirange (pg_proc, 17.11 and 18.4; docs §9.21). The library has only the range-sourced overloads (RangeAggregateExtensions, NodaTimeRangeAggregateExtensions), and ValueRangesAggregateMethodCallTranslator keys on the return type, so a sequence of RangeSet has nothing to call.

Verified live: select range_intersect_agg(m) from (values (int4multirange(int4range(1,5))), (int4multirange(int4range(3,9)))) v(m) → {[3,5)}.

Npgsql's own provider has the multirange form of the intersect aggregate (RangeIntersectAgg(this IEnumerable<NpgsqlRange<T>[]>), https://www.npgsql.org/efcore/mapping/range.html).

Proposed API: IEnumerable<RangeSet<TRange, T>>.RangeAgg() → RangeSet<TRange, T> (the union of all sets) and IEnumerable<RangeSet<TRange, T>>.RangeIntersectAgg() → RangeSet<TRange, T>? (null for an empty source, as the range form does), one overload per range type as the existing ones are written, in core and the NodaTime satellite.

Translation: range_agg(m) and range_intersect_agg(m) inside a GroupBy projection, with the multirange type mapping on both sides.

Done when: both aggregates run over a RangeSet column in a live test next to the existing range_agg test, and docs/ranges.md#aggregate-a-sequence-of-ranges says they take sets too.

Found by the PostgreSQL catalogue sweep (pg_proc over anymultirange), 2026-10-17.

Activity

  1. added
    enhancement
    area/range-set
    package/nodatime
    package/efcore
    on Oct 17, 2026
  2. added
    package/core
    on Oct 17, 2026
  3. added this to the 10.0.0 milestone on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/range-setenhancementpackage/corepackage/efcorepackage/nodatime

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions