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/InMemory: compilation error for complex groupby query #24324

Closed
maumar opened this issue Mar 5, 2021 · 1 comment · Fixed by #24372
Closed

Query/InMemory: compilation error for complex groupby query #24324

maumar opened this issue Mar 5, 2021 · 1 comment · Fixed by #24372
Assignees
Labels
area-in-memory area-query 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 Mar 5, 2021

query:

ss.Set<Customer>()
                    .Select(
                        c => new
                        {
                            Key = c.CustomerID,
                            Subquery = c.Orders
                                .Select(o => new { First = o.OrderID, Second = o.Customer.City + o.CustomerID })
                                .GroupBy(x => x.Second)
                                .Select(g => new { Sum = g.Sum(x => x.First), Count = g.Count(x => x.Second.StartsWith("Lon")) }).ToList()
                        })

exception:

Expression of type 'System.Func`2[Microsoft.EntityFrameworkCore.Storage.ValueBuffer,System.Nullable`1[System.Boolean]]' cannot be used for parameter of type 'System.Func`2[Microsoft.EntityFrameworkCore.Storage.ValueBuffer,System.Boolean]' of method 'System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.Storage.ValueBuffer] Where[ValueBuffer](System.Collections.Generic.IEnumerable`1[Microsoft.EntityFrameworkCore.Storage.ValueBuffer], System.Func`2[Microsoft.EntityFrameworkCore.Storage.ValueBuffer,System.Boolean])' (Parameter 'arg1')
  Stack Trace: 
    ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)
    Expression.Call(MethodInfo method, Expression arg0, Expression arg1)
    InMemoryExpressionTranslatingExpressionVisitor.<VisitMethodCall>g__ApplyPredicate|35_1(GroupingElementExpression groupingElement, LambdaExpression lambdaExpression) line 653
    InMemoryExpressionTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 503
    InMemoryExpressionTranslatingExpressionVisitor.TranslateInternal(Expression expression) line 141
    InMemoryExpressionTranslatingExpressionVisitor.Translate(Expression expression) line 136
    InMemoryProjectionBindingExpressionVisitor.Visit(Expression expression) line 181
    InMemoryProjectionBindingExpressionVisitor.VisitNew(NewExpression newExpression) line 460
    InMemoryProjectionBindingExpressionVisitor.Visit(Expression expression) line 193
    InMemoryProjectionBindingExpressionVisitor.Translate(InMemoryQueryExpression queryExpression, Expression expression) line 69
    InMemoryQueryableMethodTranslatingExpressionVisitor.TranslateSelect(ShapedQueryExpression source, LambdaExpression selector) line 980
    QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 405
    InMemoryQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 93
    QueryableMethodTranslatingExpressionVisitor.TranslateSubquery(Expression expression) line 640
    InMemoryExpressionTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 704
    InMemoryExpressionTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 893
    InMemoryExpressionTranslatingExpressionVisitor.TranslateInternal(Expression expression) line 141
    InMemoryExpressionTranslatingExpressionVisitor.Translate(Expression expression) line 136
    InMemoryProjectionBindingExpressionVisitor.Visit(Expression expression) line 181
    InMemoryProjectionBindingExpressionVisitor.VisitNew(NewExpression newExpression) line 460
    InMemoryProjectionBindingExpressionVisitor.Visit(Expression expression) line 193
    InMemoryProjectionBindingExpressionVisitor.Translate(InMemoryQueryExpression queryExpression, Expression expression) line 69
    InMemoryQueryableMethodTranslatingExpressionVisitor.TranslateSelect(ShapedQueryExpression source, LambdaExpression selector) line 980
    QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 405
    InMemoryQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) line 93
    QueryCompilationContext.CreateQueryExecutor[TResult](Expression query) line 187
    Database.CompileQuery[TResult](Expression query, Boolean async) line 75
    QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async) line 114
    <>c__DisplayClass12_0`1.<ExecuteAsync>b__0() line 151
    CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler) line 77
    QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken) line 147
    EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken) line 100
    EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken) line 111
    ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
    EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) line 1995

note: this scenario also fails in relational, in a controlled way

@smitpatel
Copy link
Contributor

Poaching!

@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 Mar 10, 2021
@ghost ghost closed this as completed in #24372 Mar 10, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-preview3 Mar 25, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0-preview3, 6.0.0 Nov 8, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-in-memory area-query 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

Successfully merging a pull request may close this issue.

4 participants