Optimize away Coalesce for trivial cases#34002
Merged
cincuranet merged 4 commits intodotnet:mainfrom Jun 24, 2024
Merged
Conversation
Contributor
Author
|
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
Contributor
Author
|
we could also move this simplification to the factory, if we want to: (aka automatically flatten |
Contributor
Author
|
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
cincuranet
approved these changes
Jun 24, 2024
ranma42
added a commit
to ranma42/efcore
that referenced
this pull request
Jun 24, 2024
dotnet#33715 and dotnet#34002 were developed concurrently. Their merge does not build because of some changes in the types returned by `ISqlExpressionFactory`.
Contributor
Author
|
@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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changeset contains:
COALESCEis not optimized away where it is the actual target of the testISqlExpressionFactoryinterface 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.Coalesceimplementation that automatically simplifies the expression for trivial cases:COALESCE(null, x)->xCOALESCE(nonNullableConstant, x)->nonNullableConstantCOALESCE(nonNullableColumn, x)->nonNullableColumnContributes to #33890 (the Cosmos part is missing).