-
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
Query: Rownumber conversion needs better logic to figure out partitions #26756
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
Servicing-approved
type-bug
Milestone
Comments
smitpatel
added a commit
that referenced
this issue
Jan 26, 2022
Resolves #26756 For property access on optional dependents sharing column with principal, we generate CaseExpression. In order to match them during join key search, we updated our recursive function to match shape of the test in CaseExpression which incorrectly matched similar structure outside of case block causing somewhat wrong join key to be extracted. While join key in itself could work, when generating partitions out of it due to paging operation, it gives incorrect results. The fix is to match the special structure of CaseExpression.Test separately. Also made the key comparison match more robust by only allowing column or case block to appear in condition. Other structures don't represent part of join key in a comparison. Null checks for join keys are handled separately so that we only remove null checks which are indeed used in comparison with other columns in other operations.
smitpatel
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Jan 26, 2022
smitpatel
added a commit
that referenced
this issue
Feb 2, 2022
Resolves #26756 For property access on optional dependents sharing column with principal, we generate CaseExpression. In order to match them during join key search, we updated our recursive function to match shape of the test in CaseExpression which incorrectly matched similar structure outside of case block causing somewhat wrong join key to be extracted. While join key in itself could work, when generating partitions out of it due to paging operation, it gives incorrect results. The fix is to match the special structure of CaseExpression.Test separately. Also made the key comparison match more robust by only allowing column or case block to appear in condition. Other structures don't represent part of join key in a comparison. Null checks for join keys are handled separately so that we only remove null checks which are indeed used in comparison with other columns in other operations.
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.
customer-reported
Servicing-approved
type-bug
Query like this
When converting rownumber (Apply coming from SelectMany) has predicate on Select as
p.Id != null && p.Id == c.ParentId && c.SomeNullableDateTime != null
We end up pulling the last term even though that is not part of join key and shouldn't be in partitions.
Faulty code which causes match
efcore/src/EFCore.Relational/Query/SqlExpressions/SelectExpression.cs
Lines 2340 to 2341 in e451959
The text was updated successfully, but these errors were encountered: