-
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
Fix to #16092 - Query: Simplify case blocks in SQL tree #20966
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this is part of null semantics? What is specific nullability information you need to apply this optimization?
@smitpatel it's not rly part of null semantics. it needs to happen before null semantics. I can put it in a separate visitor, as mentioned in a comment |
Does it need to know parameter values? |
updated |
src/EFCore.Relational/Query/Internal/CaseWhenFlatteningExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
c643051
to
b134660
Compare
updated |
src/EFCore.Relational/Query/Internal/CaseSimplifyingExpressionVisitor.cs
Show resolved
Hide resolved
ping |
var matchingCaseBlock = caseComponent.WhenClauses.FirstOrDefault(wc => sqlConstantComponent.Equals(wc.Result)); | ||
if (matchingCaseBlock != null) | ||
{ | ||
return matchingCaseBlock.Test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly visit recursively. Also write a regression test for it.
src/EFCore.Relational/Query/Internal/CaseSimplifyingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Query/Internal/CaseSimplifyingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
src/EFCore.Relational/Query/Internal/CaseSimplifyingExpressionVisitor.cs
Show resolved
Hide resolved
src/EFCore.Relational/Query/Internal/CaseSimplifyingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
Adding optimization to during post processing Trying to match CASE block that corresponds to CompareTo translation. If that case block is compared to 0, 1 or -1 we can simplify it to simple comparison. Also added generic CASE block optimization, when constant is compared to CASE block, and that constant is one of the results Fixes #16092
@smitpatel updated |
Adding optimization to during post processing (null semantics)
Trying to match CASE block that corresponds to CompareTo translation. If that case block is compared to 0, 1 or -1 we can simplify it to simple comparison.
Also added generic CASE block optimization, when constant is compared to CASE block, and that constant is one of the results
Fixes #16092