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 (NotEqual is not defined between ValueBuffer and ValueBuffer) for query with GroupJoin-SelectMany-DefaultIfEmpty with order by on the inner sequence #12788

Closed
maumar opened this issue Jul 25, 2018 · 1 comment

Comments

@maumar
Copy link
Contributor

maumar commented Jul 25, 2018

query:

                var query = from l1 in ctx.LevelOne
                            join l2 in ctx.LevelTwo.OrderBy(ee => ee.Name) on l1.Id equals l2.Level1_Optional_Id into groupJoin
                            from l2 in groupJoin.DefaultIfEmpty()
                            select l2 == null ? null : l2.Name;

                var result = query.ToList();

OrderBy(ee => ee.Name) causes the error

query plan:

(QueryContext queryContext) => IEnumerable<string> _InterceptExceptions(
|__ source: IEnumerable<string> _Select(
|   |__ 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 [l1].[Id]
|   |   |   |   |       FROM [LevelOne] AS [l1], 
|   |   |   |   |__ shaper: ValueBufferShaper), 
|   |   |   |__ inner: IEnumerable<ValueBuffer> _ShapedQuery(
|   |   |   |   |__ queryContext: queryContext, 
|   |   |   |   |__ shaperCommandContext: SelectExpression: 
|   |   |   |   |       SELECT [ee0].[Level1_Optional_Id]
|   |   |   |   |       FROM [LevelTwo] AS [ee0]
|   |   |   |   |       ORDER BY [ee0].[Name], 
|   |   |   |   |__ shaper: ValueBufferShaper), 
|   |   |   |__ outerKeySelector: (ValueBuffer l1) => (Nullable<int>)int TryReadValue(l1, 0, Level1.Id), 
|   |   |   |__ innerKeySelector: (ValueBuffer l2) => Nullable<int> TryReadValue(l2, 0, Level2.Level1_Optional_Id), 
|   |   |   |__ resultSelector: (ValueBuffer l1 | IEnumerable<ValueBuffer> groupJoin) => TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>> CreateTransparentIdentifier(
|   |   |       |__ outer: l1, 
|   |   |       |__ inner: groupJoin)), 
|   |   |__ collectionSelector: (TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>> t0) => IEnumerable<ValueBuffer> DefaultIfEmpty(t0.Inner), 
|   |   |__ resultSelector: (TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>> t0 | ValueBuffer l2) => TransparentIdentifier<TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>>, ValueBuffer> CreateTransparentIdentifier(
|   |       |__ outer: t0, 
|   |       |__ inner: l2)), 
|   |__ selector: (TransparentIdentifier<TransparentIdentifier<ValueBuffer, IEnumerable<ValueBuffer>>, ValueBuffer> t1) => t1.Inner?.Name), 
|__ contextType: TestModels.ComplexNavigationsModel.ComplexNavigationsContext, 
|__ logger: DiagnosticsLogger<Query>, 
|__ queryContext: queryContext)

exception:

The binary operator NotEqual is not defined for the types 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer' and 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer'.
	at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)
	at System.Linq.Expressions.Expression.NotEqual(Expression left, Expression right)
	at Microsoft.EntityFrameworkCore.Query.Expressions.Internal.NullConditionalExpression.Reduce()
	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.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)
@divega
Copy link
Contributor

divega commented Nov 2, 2018

Closing in favor of #13860 that is customer reported and contains workarounds.

@divega divega closed this as completed Nov 2, 2018
@divega divega removed this from the 3.0.0 milestone Nov 2, 2018
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants