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 queries with Concat on two entities and scalar projection on top #9007

Closed
maumar opened this issue Jun 28, 2017 · 6 comments · Fixed by #17766
Closed
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

@maumar
Copy link
Contributor

maumar commented Jun 28, 2017

query:

context.Gears.Concat(context.Gears).Select(g => g.Nickname);

exception:

The input sequence must have items of type 'Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear', but it has items of type 'System.String'.
Parameter name: inputInfo
	at Remotion.Linq.Clauses.ResultOperatorBase.CheckSequenceItemType(StreamedSequenceInfo inputInfo, Type expectedItemType)
	at Remotion.Linq.Clauses.ResultOperators.ConcatResultOperator.GetOutputDataInfo(IStreamedDataInfo inputInfo)
	at Remotion.Linq.QueryModel.<GetOutputDataInfo>b__0(IStreamedDataInfo current, ResultOperatorBase resultOperator)
	at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
	at Remotion.Linq.QueryModel.GetOutputDataInfo()
	C:\git\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs(570,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TrackResults(QueryModel queryModel)
	C:\git\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs(287,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
	C:\git\EntityFramework\src\EFCore.Relational\Query\RelationalQueryModelVisitor.cs(1157,0): at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
	C:\git\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs(171,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
	C:\git\EntityFramework\src\EFCore\Storage\Database.cs(70,0): 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()
	C:\git\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs(164,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
	C:\git\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs(103,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_0`1.<Execute>b__0()
	C:\git\EntityFramework\src\EFCore\Query\Internal\CompiledQueryCache.cs(69,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
	C:\git\EntityFramework\src\EFCore\Query\Internal\CompiledQueryCache.cs(44,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
	C:\git\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs(99,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
	C:\git\EntityFramework\src\EFCore\Query\Internal\EntityQueryProvider.cs(62,0): 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)

Looks like we are creating invalid QM that relinq can't quite handle when we ask for it's OutputDataInfo during tracking

@maumar
Copy link
Contributor Author

maumar commented Jun 28, 2017

The issue is introduced by ConvertEntityQueryableToSubQuery in QueryOptimizer

@flipchart
Copy link

Hitting this issue in a project ported from EF 6. Any workarounds for now?

@smitpatel
Copy link
Contributor

@flipchart - Try following query
context.Gears.Select(g => g.Nickname).Concat(context.Gears.Select(g => g.Nickname));

@bdariusb
Copy link

same issue here, either using Concat() or Union()

@generik0
Copy link

@ajcvickers Any update? I have same issue if:
Demo code:

var actuals = db.Reports.Include(x => x.ReportsDetails).OrderBy(x=>x.Time)
                .Where(x => ids.Contains(x.Id)).Take(1);
            var actualsBetween =   db.Reports.Include(x => x.ReportsDetails)
                .Where(x => ids.Contains(x.Id) && fromDateTime <= x.Time && x.Time <= toDateTime);
            actuals = actuals.Concat(actualsBetween);

@ajcvickers
Copy link
Contributor

@generik0 This issue is in the Backlog milestone. This means that it is not going to happen for the 3.0 release. We will re-assess the backlog following the 3.0 release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

@smitpatel smitpatel added the verify-fixed This issue is likely fixed in new query pipeline. label Sep 4, 2019
@smitpatel smitpatel self-assigned this Sep 4, 2019
@ajcvickers ajcvickers modified the milestones: Backlog, 3.1.0 Sep 4, 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 verify-fixed This issue is likely fixed in new query pipeline. labels Sep 9, 2019
smitpatel added a commit that referenced this issue Sep 9, 2019
@smitpatel smitpatel modified the milestones: 3.1.0, 3.0.0 Sep 11, 2019
smitpatel added a commit that referenced this issue Sep 11, 2019
Covers EFCore.Specs.Tests Query folder

Resolves #8366
Resolves #8582
Resolves #8722
Resolves #9007
Resolves #9254
Resolves #12574
Resolves #12579
Resolves #12598
Resolves #12786
Resolves #12787
Resolves #12794
Resolves #12806
Resolves #12827
Resolves #12873
Resolves #14900
Resolves #15862
Resolves #16157
Resolves #17240
Resolves #17243


Close #12889
Close #17243
smitpatel added a commit that referenced this issue Sep 11, 2019
Covers EFCore.Specs.Tests Query folder

Resolves #8366
Resolves #8582
Resolves #8722
Resolves #9007
Resolves #9254
Resolves #12574
Resolves #12579
Resolves #12598
Resolves #12786
Resolves #12787
Resolves #12794
Resolves #12806
Resolves #12827
Resolves #12873
Resolves #14900
Resolves #15862
Resolves #16157
Resolves #17240


Close #12889
Close #17243
smitpatel added a commit that referenced this issue Sep 11, 2019
Covers EFCore.Specs.Tests Query folder

Resolves #8366
Resolves #8582
Resolves #8722
Resolves #9007
Resolves #9254
Resolves #12574
Resolves #12579
Resolves #12598
Resolves #12786
Resolves #12787
Resolves #12794
Resolves #12806
Resolves #12827
Resolves #12873
Resolves #14900
Resolves #15862
Resolves #16157
Resolves #17240


Close #12889
Close #17243
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

Successfully merging a pull request may close this issue.

6 participants