-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to #6647 - Left Join (GroupJoin) always materializes elements res…
…ulting in unnecessary data pulling Problem was that for GroupJoin we would always force materialization on participating query sources. We were doing this because we are not always able to correctly divide outer elements of the GroupJoin into correct groups. However, if the GroupJoin clause is wrapped around SelectMany clause the groups don't matter because they are getting flattened by SelectMany anyway. Fix is to recognize those scenarios and only force materialization when the correct grouping actually matters. We can avoid materialization if the GroupJoin is followed by SelectMany clause (that references the grouping) and that the grouping itself is not present anywhere else in the query. This addresses optional navigations, which is the 80% case. Manually created GroupJoins that are not modeling LeftOuterJoins still require additional materialization, but this can be addressed later as the priority is not nearly as high. Other bugs fixed alongside the main change: #7722 - Query : error during compilation for queries with navigation properties and First/Single/client method operators inside a subquery. Problem here was that for some queries we don't know how to properly bind to a value buffer (when the result of binding is subquery, and not qsre). Fix/mitigation is to recognize those scenarios and force materialization on the subqueries. This can be properly addressed in later commit (i.e. by improving the binding logic) #7497 - Error calling Count() after GroupJoin() (and removed the temporary fix to #7348 and implemented a proper one) This turned out to be a chicken-and-egg problem - we had discrepancy between query sources that we marked for materialization in case of GroupJoin + result operator, and the actual client side operation that had to be performed. We had to fix the group join materialization to allow for translation of those result operators, but without fixing this issue also we would get invalid queries in some cases. Proper fix is to force client result operator only if the GroupJoin cannot be flattened. We also now do this for all result operators, not just a subset because it was possible to generate invalid queries with operaors like Count(). This is now consistent with the behavior of RequiresMaterializationExpressionVisitor. Also fixed several minor issues that were encountered once no longer do extensive materialization.
- Loading branch information
Showing
20 changed files
with
965 additions
and
489 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.