Repository navigation
fix: RangeAgg and RangeIntersectAgg skip a null input, as range_agg does (10.x, port of #361) - #369
Merged
Conversation
…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
enabled auto-merge
October 24, 2026 15:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #363
The 10.x port of #361 for 10.2.0 (#358):
git cherry-pick -xof the fix commit99a6989, merged intomainby #368 asab7458c. Againstrelease/10.xthe closing keyword closes nothing, so #363 is closed by hand after the merge.Problem
10.1.0's
RangeAgg()andRangeIntersectAgg()don't skip anullinput, though the docs call them the in-memory versions ofrange_aggandrange_intersect_agg, which skip a NULL row. With anullafter another range:RangeIntersectAgg()returnedempty(Intersect(null)isemptyfor every shape but(,), which throws);RangeAgg()threwInvalidOperationException, or built a set holdingnullfrom[null]alone.Over sets, a
nullset threwNullReferenceException. The code is identical on both lines, for the core and the NodaTime overloads.Change
main:WithoutNullsbefore every per-type overload's fold (nine core, four NodaTime) and both set overloads; the docs bullet indocs/ranges.mdand claim R48; the reflection sweepAggregateNullInputs, linked into the NodaTime tests; the set-overload test;RangeAggregateParityTests.Aggregates_OverANullableColumn_SkipTheNullRows; and the seedaggregates-fold-a-null-input.patch.main's### Breakinglines under[11.0.0-preview.1]become### Changed answersrows under[10.2.0]. The row goes above 10.x: LowerBound() and UpperBound() in a query: == null becomes WHERE FALSE and ?? loses its COALESCE (port of #349) #354'sEF Core:row in the root changelog, by area order. In the core and NodaTime changelogs it replaces "No change in this package.". Each 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 anddocs/migration.md#changed-answers-in-1020.docs/migration.md: the subsection### Check RangeAgg and RangeIntersectAgg over null rangessits under## Changed answers in 10.2.0, after 10.x: LowerBound() and UpperBound() in a query: == null becomes WHERE FALSE and ?? loses its COALESCE (port of #349) #354's, and "Before 11.0.0" reads "Before 10.2.0". The 10.x intro is kept;main's## Migration from v10.xbullets stay out.Tests
Local, SDK 10.0.402, Docker:
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 onpostgres: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 indeps.json).WithoutNullsreturning 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 newaggregates-fold-a-null-input.patchand the three existing aggregate seeds all apply and are caught.pr-hygiene.shon a simulatedsilentevent: "Labels and issue link are in order", so the[10.2.0]### Changed answersrow 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