-
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
Optimize away Coalesce for trivial cases #34002
Conversation
Note that this change only takes care of trivial optimizations (which is nonetheless convenient to centralize, as shown by the commit that cleans up repeated copies of this pattern). More general optimizations for |
f6a734c
to
a8096ad
Compare
we could also move this simplification to the factory, if we want to: efcore/src/EFCore.Relational/Query/Internal/SqlExpressionSimplifyingExpressionVisitor.cs Lines 65 to 93 in d6fd3d2
(aka automatically flatten |
The first 2 commits of this PR now also belong to: hence I am marking this as draft like the other dependent PRs I posted 😇 |
This makes it possible to perform transformations within the factory.
a8096ad
to
faa3195
Compare
dotnet#33715 and dotnet#34002 were developed concurrently. Their merge does not build because of some changes in the types returned by `ISqlExpressionFactory`.
@cincuranet sorry, I did not notice that another change was merged that was not a syntax conflict, but that still resulted in a build issue. I just pushed #34078 to fix this. |
This changeset contains:
COALESCE
is not optimized away where it is the actual target of the testISqlExpressionFactory
interface that grants its members more flexibility on the instance type of the returned expressions; even though it is technically a breaking change, this only has impact on providers (and even then, the expected impact is limited, as seen in the changes required on the SQLite and SqlServer providers)SqlExpressionFactory.Coalesce
implementation that automatically simplifies the expression for trivial cases:COALESCE(null, x)
->x
COALESCE(nonNullableConstant, x)
->nonNullableConstant
COALESCE(nonNullableColumn, x)
->nonNullableColumn
Contributes to #33890 (the Cosmos part is missing).