Native GroupBy follow-ups: coverage gaps + review nits (from EF-344)

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Follow-ups from the EF-344 final whole-branch review (native LINQ query rewrite sub-project SP6, epic EF-322). EF-344 shipped native GroupBy(key).Select(aggregate)$group; these are non-blocking items deliberately deferred out of that branch (the branch was merge-ready without them).

      Coverage gaps (correct results today via driver-LINQ fallback; candidates to make native):

      • Non-member / computed grouping keys fall back. NativeGroupByBinder.TryBindGroupKey accepts only a plain member access or an anonymous/new of member accesses. Keys like EF.Property<T>(o, "X") (a MethodCallExpression) and computed keys (g => g.OrderDate.Year) fall back (correct results). Making EF.Property keys and/or computed keys native is a follow-on.
      • User-supplied GroupBy(key, resultSelector) overload declines. The QMTEV TranslateGroupBy marks non-native when resultSelector != null, so the fused overload falls back. Supporting it natively is a follow-on.
      • Decline discriminator is Join-family only. MarkGroupByFallbackUnsafe() fires for a group-first GroupBy combined with Join/GroupJoin/LeftJoin (the one shape where driver-LINQ returned silently wrong data). Other correlated operators over a group-first source (SelectMany/set-ops/Concat) are NOT marked fallback-unsafe. No such shape is currently known to return wrong data via the fallback, but if one is found it needs the same decline treatment — residual "too-narrow" risk worth a targeted audit.

      Test / code nits:

      • Add a functional MongoQueryMode.NativeOnly test that Min/Max/Average group accumulators go native (currently covered by binder unit tests + the MONGODB_EF_NATIVE_ONLY spec sweep, but no dedicated functional NativeOnly case alongside the existing Count/Sum ones).
      • NativeGroupByBinder.TryBindGroupProjection has an unused groupingParameterShaper parameter (retained for signature stability during EF-344; it's a static internal helper, so it can just be dropped).
      • The binder recomputes composite-key-ness inline (isComposite) instead of reusing MongoGrouping.IsCompositeKey.

      Context: design docs/superpowers/specs/2026-07-08-native-groupby-design.md; the as-built behavior is documented in src/MongoDB.EntityFrameworkCore/Query/AGENTS.md (EF-SP6 GroupBy note).

            Assignee:
            Unassigned
            Reporter:
            Arthur Vickers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: