Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Entity Framework core 1 Group By after Union throw “must be reducible node” Exception #6658

Closed
MohammadAkbari opened this issue Oct 1, 2016 · 8 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-2.0 type-bug
Milestone

Comments

@MohammadAkbari
Copy link

MohammadAkbari commented Oct 1, 2016

I need unoin two query and after union Group By that, but throw "must be reducible node" Exception. in following sample code are:

public class ForumPost
{
    public int ForumPostId { get; set; }
    public string Message { get; set; }
    public bool Deleted { get; set; }
    public int ForumTopicId { get; set; }
    public virtual ForumTopic ForumTopic { get; set; }
}

var query1 = _dbContext.ForumPosts
    .Where(e => e.Deleted == true);

var query2 = _dbContext.ForumPosts
    .Where(e => e.Deleted == false);

var query =  query1.Union(query2);

var list = query.GroupBy(e => e.ForumTopicId)
    .Select(group => new
    {
        group.Key,
        Total = group.Count()
    }).Take(10)
    .ToList();

Does anyone faced with this problem?

@rowanmiller rowanmiller added this to the 1.1.0 milestone Oct 3, 2016
@maumar maumar modified the milestones: 1.2.0, 1.1.0 Oct 5, 2016
@adrien-constant
Copy link

Is there an ETA on this? I have the same exception, and I have to call ToArray() before filtering, which obviously is bad for performances.

@rowanmiller
Copy link
Contributor

It's on our list to investigate for the next release (1.2.0). Once we understand the work required, we'll have a better idea of where this fits.

@maumar
Copy link
Contributor

maumar commented Apr 12, 2017

This still reproduces on current bits. We generate the following query plan:

(QueryContext queryContext) => IEnumerable<<>f__AnonymousType0<int, int>> _InterceptExceptions(
    source: IEnumerable<<>f__AnonymousType0<int, int>> _Select(
        source: IEnumerable<IGrouping<int, ForumPost>> Take(
            source: IEnumerable<IGrouping<int, ForumPost>> _GroupBy(
                source: IEnumerable<ForumPost> Union(
                    first: IEnumerable<ForumPost> _ShapedQuery(
                        queryContext: queryContext, 
                        shaperCommandContext: SelectExpression: 
                            SELECT [e1].[ForumPostId], [e1].[Deleted], [e1].[ForumTopicId], [e1].[Message]
                            FROM [ForumPosts] AS [e1]
                            WHERE [e1].[Deleted] = 1, 
                        shaper: BufferedEntityShaper<ForumPost>), 
                    second: IEnumerable<ForumPost> _ShapedQuery(
                        queryContext: queryContext, 
                        shaperCommandContext: SelectExpression: 
                            SELECT [e2].[ForumPostId], [e2].[Deleted], [e2].[ForumTopicId], [e2].[Message]
                            FROM [ForumPosts] AS [e2]
                            WHERE [e2].[Deleted] = 0, 
                        shaper: BufferedEntityShaper<ForumPost>)), 
                keySelector: (ForumPost e) =>  ---> [e] <--- .ForumTopicId, 
                elementSelector: (ForumPost e) =>  ---> [e] <--- ), 
            count: int GetParameterValue(
                queryContext: queryContext, 
                parameterName: "__p_0")), 
        selector: (IGrouping<int, ForumPost> group) => new <>f__AnonymousType0<int, int>(
            group.Key, 
            int Count(group)
        )), 
    contextType: Repro6658.MyContext, 
    logger: SensitiveDataLogger<IQueryCompilationContextFactory>, 
    queryContext: queryContext)

@smitpatel
Copy link
Member

Which node is non-reducible?

@maumar
Copy link
Contributor

maumar commented Apr 12, 2017

key selector and element selector on the GroupBy, updated the query plan with debug version instead

@maumar maumar assigned smitpatel and unassigned maumar Apr 13, 2017
@smitpatel smitpatel removed this from the 2.0.0 milestone Apr 18, 2017
smitpatel added a commit that referenced this issue Apr 18, 2017
Add test for set operation followed group by not translating correctly Issue #6658
@smitpatel smitpatel removed their assignment Apr 18, 2017
@ajcvickers ajcvickers added this to the Backlog milestone Apr 19, 2017
smitpatel added a commit that referenced this issue Apr 20, 2017
Add test for set operation followed group by not translating correctly Issue #6658
smitpatel added a commit that referenced this issue Apr 20, 2017
Add test for set operation followed group by not translating correctly Issue #6658
@ajcvickers ajcvickers changed the title Entity Framework core 1 Group By after Union throw “must be reducible node” Exception Query: Entity Framework core 1 Group By after Union throw “must be reducible node” Exception May 16, 2018
@qqliuyifanqq
Copy link

So is this problem solved?

@smitpatel smitpatel added the verify-fixed This issue is likely fixed in new query pipeline. label Jul 2, 2019
smitpatel added a commit that referenced this issue Jul 2, 2019
…fter GroupBy

Resolves #12826
Resolves #6658
Part of #15711
Resolves #15853
Resolves #12799
Resolves #12476
Resolves #11976

There are way too many existing issues are resolved by this PR. I haven't added regression test or verified each of them so I have put Verify-Fixed label on them for now.
smitpatel added a commit that referenced this issue Jul 2, 2019
…fter GroupBy

Resolves #12826
Resolves #6658
Part of #15711
Resolves #15853
Resolves #12799
Resolves #12476
Resolves #11976

There are way too many existing issues are resolved by this PR. I haven't added regression test or verified each of them so I have put Verify-Fixed label on them for now.
smitpatel added a commit that referenced this issue Jul 2, 2019
…fter GroupBy

Resolves #12826
Resolves #6658
Part of #15711
Resolves #15853
Resolves #12799
Resolves #12476
Resolves #11976

There are way too many existing issues are resolved by this PR. I haven't added regression test or verified each of them so I have put Verify-Fixed label on them for now.
@smitpatel smitpatel reopened this Jul 2, 2019
@smitpatel
Copy link
Member

Re-opening to add more coverage for set operations and group by interactions.

@smitpatel
Copy link
Member

Filed #17607 for further test coverage.

@smitpatel smitpatel added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed verify-fixed This issue is likely fixed in new query pipeline. labels Sep 4, 2019
@smitpatel smitpatel modified the milestones: Backlog, 3.0.0 Sep 4, 2019
@smitpatel smitpatel self-assigned this Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-2.0 type-bug
Projects
None yet
Development

No branches or pull requests

7 participants