Skip to content

Query: SQL group by when aggregate operators have complex expression #11976

Closed

Description

@smitpatel
        [ConditionalFact]
        public virtual void GroupBy_Property_Select_Sum()
        {
            AssertQueryScalar<Order>(os => os.GroupBy(o => o.CustomerID).Select(g => g.Sum(o => o.OrderID + 5)));
        }

Is client evaluated since the expression inside Sum is not member expression. That is our current logic to avoid issues with unmapped properties. In general we can relax the criteria but currently we decide in RequiresMaterialization if we can translate of not. At that point we cannot accurately know if we can translate it or not. (materialization tells client group by vs server group by). We can remove strict check and allow translation of more patterns but if something which cannot be translated is encountered then we fail.

As an effective fix for this (and other issue with joins #10012 ) we can pull the selector into GroupResultOperator (with custom operator) and we can make determination of group by during translation strictly.

Activity

  1. added this to the Backlog milestone on May 14, 2018
  2. modified the milestones: Backlog, on Jun 5, 2018
  3. smitpatel commented on Jul 31, 2018

    @smitpatel
    ContributorAuthor

    Dependent on #12089

  4. modified the milestones: , 2.1.4, 3.0.0 on Aug 3, 2018
  5. 14 remaining items

  6. added 4 commits that reference this issue on Jul 2, 2019
    8497da5
    4b4a9ea
    50a98fd
    d68c9fb
  7. modified the milestones: 3.0.0, on Jul 2, 2019
  8. modified the milestones: , 3.0.0 on Nov 11, 2019
  9. added theissue type on Jun 15, 2025
  10. marked Group By in EF 2.1.1 #12609 as a duplicate of this issue on Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions