Skip to content

fix: RangeAgg and RangeIntersectAgg skip a null input, as range_agg does (10.x, port of #361) - #369

Merged
CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/363-aggregates-skip-null-10.x
Oct 24, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/363-aggregates-skip-null-10.x

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #363

The 10.x port of #361 for 10.2.0 (#358): git cherry-pick -x of the fix commit 99a6989, merged into main by #368 as ab7458c. Against release/10.x the closing keyword closes nothing, so #363 is closed by hand after the merge.

Problem

10.1.0's RangeAgg() and RangeIntersectAgg() don't skip a null input, though the docs call them the in-memory versions of range_agg and range_intersect_agg, which skip a NULL row. With a null after another range:

  • RangeIntersectAgg() returned empty (Intersect(null) is empty for every shape but (,), which throws);
  • RangeAgg() threw InvalidOperationException, or built a set holding null from [null] alone.

Over sets, a null set threw NullReferenceException. The code is identical on both lines, for the core and the NodaTime overloads.

Change

Tests

Local, SDK 10.0.402, Docker:

  • Full suite, EF Core 10.0.0 floor, postgres:16-alpine: all eight projects pass (core 1399, NodaTime 239, EF 305, EF NodaTime 91, ASP.NET Core 92, conventions 406, integration 283, infinity-disabled 4).
  • RangeAggregateParityTests: 7/7 on postgres:18-alpine, and 7/7 on EF Core 10.0.13 with Npgsql 10.0.3 (-p:EfFloat=10.0.13 -p:NpgsqlEfFloat=10.0.3, versions confirmed in deps.json).
  • Fix reverted on this branch (WithoutNulls returning its input): both new core tests and the NodaTime sweep fail, and the nullable-column test fails on 116 results. Restored afterwards.
  • dotnet run tools/oracles.cs seeds: on this branch the new aggregates-fold-a-null-input.patch and the three existing aggregate seeds all apply and are caught.
  • pr-hygiene.sh on a simulated silent event: "Labels and issue link are in order", so the [10.2.0] ### Changed answers row links 10.x: RangeIntersectAgg returns empty over a sequence holding a null range, where range_intersect_agg skips the NULL; RangeAgg throws (port of #361) #363.

🤖 Generated with Claude Code

…oes (#361)

PostgreSQL's range_agg and range_intersect_agg skip a NULL row, and the docs
call the two the in-memory versions of those aggregates. They didn't skip a null:
RangeIntersectAgg folded it in as Intersect(null), which is empty for every shape
but (,), where it throws, and RangeAgg handed it to RangeSet.From, which threw
while sorting or built a set holding null. Over sets, a null set threw.

Every per-type overload (nine in the core, four in the NodaTime package) and both
set overloads now drop nulls before folding. A source of nothing but nulls is an
empty source, which keeps the documented zero-rows difference for RangeAgg. The
filter sits where each overload calls its fold, so the three aggregate seeds
apply as they were; all three are still caught.

Tests: a reflection sweep over every per-type overload, linked into the NodaTime
tests; the set overloads; and RangeAggregateParityTests over a nullable range,
multirange and NodaTime range column with the NULL row at every position, which
fails on 116 results with the filter removed. That revert is kept as the seed
aggregates-fold-a-null-input.patch. Claim R48 quotes the new docs/ranges.md bullet.

Found-By: US
Defect-Class: ALG

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 99a6989)
@CaffeinatedCoder CaffeinatedCoder added this to the 10.2.0 milestone Oct 24, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred breaking Changes an answer or a signature — needs a major area/ranges Range unions, variants and the shape engines area/range-set RangeSet and multirange algebra package/nodatime Affects CodoMetis.ValueRanges.NodaTime package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference labels Oct 24, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 87b473a into release/10.x Oct 24, 2026
10 of 13 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/363-aggregates-skip-null-10.x branch October 24, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/range-set RangeSet and multirange algebra area/ranges Range unions, variants and the shape engines breaking Changes an answer or a signature — needs a major bug Something isn't working package/core Affects CodoMetis.ValueRanges package/nodatime Affects CodoMetis.ValueRanges.NodaTime severity/low Cosmetic, message or documentation-level difference silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant