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 for query with subquery, Any() result operator and DefaultIfEmpty #12437

Closed
maumar opened this issue Jun 20, 2018 · 0 comments
Assignees
Labels
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 Jun 20, 2018

query using Northwind model:

(from e in ctx.Employees
                          .Where(e => e.EmployeeID == NonExistentID)
                          .Select(e => e.EmployeeID)
                          .DefaultIfEmpty()
select e).Any()

query plan:

IEnumerable<IEnumerable<uint>> _InterceptExceptions(
    source: IEnumerable<IEnumerable<uint>> _ToSequence(() => IEnumerable<uint> DefaultIfEmpty(IEnumerable<uint> _DefaultIfEmptyShapedQuery(
                queryContext: Unhandled parameter: queryContext, 
                shaperCommandContext: SelectExpression: 
                    SELECT CASE
                        WHEN EXISTS (
                            SELECT 1
                            FROM (
                                SELECT NULL AS [empty]
                            ) AS [empty]
                            LEFT JOIN (
                                SELECT [e].[EmployeeID]
                                FROM [Employees] AS [e]
                                WHERE [e].[EmployeeID] = -1
                            ) AS [t] ON 1 = 1)
                        THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
                    END, 
                shaper: TypedProjectionShaper<ValueBufferShaper, ValueBuffer, uint>))), 
    contextType: TestModels.Northwind.NorthwindRelationalContext, 
    logger: DiagnosticsLogger<Query>, 
    queryContext: Unhandled parameter: queryContext)

exception:

System.ArgumentException : Expression of type 'System.Collections.Generic.IEnumerable`1[System.Collections.Generic.IEnumerable`1[System.UInt32]]' cannot be used for return type 'System.Collections.Generic.IEnumerable`1[System.Boolean]'
	at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression& body, ReadOnlyCollection`1 parameters)
	at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, String name, Boolean tailCall, IEnumerable`1 parameters)
	at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, Boolean tailCall, IEnumerable`1 parameters)
	at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, ParameterExpression[] parameters)
	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)
	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 System.Linq.Queryable.Any[TSource](IQueryable`1 source)
@ajcvickers ajcvickers added this to the Backlog milestone Jun 27, 2018
@smitpatel smitpatel self-assigned this Dec 6, 2019
smitpatel added a commit that referenced this issue Dec 6, 2019
@smitpatel smitpatel modified the milestones: Backlog, 3.1.0 Dec 6, 2019
@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 try-on-latest labels Dec 6, 2019
smitpatel added a commit that referenced this issue Dec 6, 2019
smitpatel added a commit that referenced this issue Dec 6, 2019
smitpatel added a commit that referenced this issue Dec 6, 2019
smitpatel added a commit that referenced this issue Dec 6, 2019
smitpatel added a commit that referenced this issue Dec 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

No branches or pull requests

3 participants