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: compilation error (dangling qsre) for query with SelectMany, order by and GroupBy aggregate #12799

Closed
maumar opened this issue Jul 25, 2018 · 3 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Jul 25, 2018

query:

                var query = (from c in ctx.Customers
                             join o in ctx.Orders.OrderBy(e => e.OrderID)
                                 on c.CustomerID equals o.CustomerID into grouping
                             from o in grouping.DefaultIfEmpty()
                             select c)
                    .GroupBy(c => c.CustomerID)
                    .Select(
                        g => new
                        {
                            g.Key,
                            Max = g.Max(c => c.City)
                        });

                var result = query.ToList();

query plan:

(QueryContext queryContext) => IEnumerable<<>f__AnonymousType218<string, string>> _InterceptExceptions(
|__ source: IEnumerable<<>f__AnonymousType218<string, string>> _Select(
|   |__ source: IEnumerable<IGrouping<string, ValueBuffer>> _GroupBy(
|   |   |__ source: IEnumerable<TransparentIdentifier<TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>>, ValueBuffer>> _SelectMany(
|   |   |   |__ source: IEnumerable<TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>>> _GroupJoin(
|   |   |   |   |__ outer: IEnumerable<ValueBuffer> _ShapedQuery(
|   |   |   |   |   |__ queryContext: queryContext, 
|   |   |   |   |   |__ shaperCommandContext: SelectExpression: 
|   |   |   |   |   |       SELECT [c0].[CustomerID]
|   |   |   |   |   |       FROM [Customers] AS [c0], 
|   |   |   |   |   |__ shaper: ValueBufferShaper), 
|   |   |   |   |__ inner: IEnumerable<ValueBuffer> _ShapedQuery(
|   |   |   |   |   |__ queryContext: queryContext, 
|   |   |   |   |   |__ shaperCommandContext: SelectExpression: 
|   |   |   |   |   |       SELECT [e2].[CustomerID]
|   |   |   |   |   |       FROM [Orders] AS [e2]
|   |   |   |   |   |       ORDER BY [e2].[OrderID], 
|   |   |   |   |   |__ shaper: ValueBufferShaper), 
|   |   |   |   |__ outerKeySelector: (ValueBuffer c) => string TryReadValue(c, 0, Customer.CustomerID), 
|   |   |   |   |__ innerKeySelector: (ValueBuffer o) => string TryReadValue(o, 0, Order.CustomerID), 
|   |   |   |   |__ resultSelector: (ValueBuffer c | IEnumerable<ValueBuffer> grouping) => TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>> CreateTransparentIdentifier(
|   |   |   |       |__ outer: c, 
|   |   |   |       |__ inner: grouping)), 
|   |   |   |__ collectionSelector: (TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>> t0) => IEnumerable<ValueBuffer> DefaultIfEmpty(t0.Inner), 
|   |   |   |__ resultSelector: (TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>> t0 | ValueBuffer o) => TransparentIdentifier<TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>>, ValueBuffer> CreateTransparentIdentifier(
|   |   |       |__ outer: t0, 
|   |   |       |__ inner: o)), 
|   |   |__ keySelector: (TransparentIdentifier<TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>>, ValueBuffer> t1) => string TryReadValue(t1.Outer.Outer, 0, Customer.CustomerID), 
|   |   |__ elementSelector: (TransparentIdentifier<TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>>, ValueBuffer> t1) => t1.Outer.Outer), 
|   |__ selector: (IGrouping<string, ValueBuffer> g) => new { 
|           g.Key, 
|           string Max(IEnumerable<string> _Select(
|           |__ source: g, 
|           |__ selector: (ValueBuffer c) =>  ---> [c] <--- .City))
|        }), 
|__ contextType: TestModels.Northwind.NorthwindRelationalContext, 
|__ logger: DiagnosticsLogger<Query>, 
|__ queryContext: queryContext)

exception:

System.ArgumentException : must be reducible node
	at System.Linq.Expressions.Expression.ReduceAndCheck()
	at System.Linq.Expressions.Expression.ReduceExtensions()
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExtensionExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteMemberExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpressionFreeTemps(Expression expression, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.Rewrite[T](Expression`1 lambda)
	at System.Linq.Expressions.Expression`1.Accept(StackSpiller spiller)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteLambdaExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteNewExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpressionFreeTemps(Expression expression, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.Rewrite[T](Expression`1 lambda)
	at System.Linq.Expressions.Expression`1.Accept(StackSpiller spiller)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteLambdaExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
	at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpressionFreeTemps(Expression expression, Stack stack)
	at System.Linq.Expressions.Compiler.StackSpiller.Rewrite[T](Expression`1 lambda)
	at System.Linq.Expressions.Expression`1.Accept(StackSpiller spiller)
	at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
	at System.Linq.Expressions.Expression`1.Compile()
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateExecutorLambda[TResults]()
	at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.CreateExecutorLambda[TResults]()
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
	at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel)
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_0`1.<Execute>b__0()
	at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
	at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
	at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
	at Remotion.Linq.QueryableBase`1.GetEnumerator()
	at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
	at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
@maumar
Copy link
Contributor Author

maumar commented Jul 25, 2018

could be same underlying issue as #12794

@divega
Copy link
Contributor

divega commented Jun 24, 2019

As per triage discussion, removing propose-punt. IIRC, we said this will likely going to be fixed for 3.0.

@smitpatel
Copy link
Contributor

Enabled test GroupJoin_GroupBy_Aggregate_2

@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. 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 modified the milestones: 3.0.0, 3.0.0-preview7 Jul 2, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0-preview7, 3.0.0 Nov 11, 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. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants