-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[2.0/2.1] Query with manual groupjoin and another groupjoin/nav access in result selector based on different join predicate may return additional results #12200
Comments
Problem here is that both GroupJoin and b.MainDevice.* translates to LEFT JOIN which are based on different join conditions. The query we generate looks like this:
What we should probably do is detect manually generated groupjoins, and any other groupjoins inside that groupjoin's result selector that are based on different keys should be translated to the subquery instead of LOJ. Optional navigation -> LOJ translation was introduced in 2.x |
We should translate to something like this: from b in ctx.Branch
join d in ctx.Device on b.BranchId equals d.BranchId into ds
select new
{
b.BranchId,
Device = b.MainDevice != null ? (from md in ctx.Device
where md.DeviceId == b.MainDeviceId
select md.Name).FirstOrDefault() : null,
List = ds.ToList()
}; |
Simpler repro: var query = from b in ctx.Branch
join d in ctx.Device on b.BranchId equals d.BranchId into grouping
select b.MainDevice != null ? b.MainDevice.Name : null;
var result = query.ToList(); |
Generated query plan for the above case:
Problem here is that outer shaper for client GroupJoin is When we process client group join, trying to place inners into correct buckets we check if the outers are the same (keep adding to the bucket) or different (need to open another bucket). However, in the case above, outer will differ even when the Branch is the same - this is because outer is a composite of Branch and value buffer. We should detect where client groupjoins are present to the query and for those cases translate all related navs into subqueries, rather than joins. |
currently this fails in new nav expansion pipeline:
|
Blocked on #17068 |
As per #17068, we don't process GroupJoin since it cannot be translated to server. Hence above queries won't work post 3.0. Closing as not needed. |
Describe what is not working as expected.
GroupJoin get more data than outer in special case.
Steps to reproduce
Expected 3 datas, and get 4. And if change
MainDeviceName = b.MainDevice != null ? b.MainDevice.Name : null,
tob.MainDevice
, it works well. That happen with efcore2.1/2.0, but not in 1.1.Further technical details
EF Core version:
2.1.0
Database Provider:
Microsoft.EntityFrameworkCore.SqlServer
Operating system:
Win10x64 10.0.17134.81
IDE:
Visual Studio 2017 15.8prev2
The text was updated successfully, but these errors were encountered: