Cosmos: Modernize materializer & subdocument projectionbinding#38550
Cosmos: Modernize materializer & subdocument projectionbinding#38550JoasE wants to merge 281 commits into
Conversation
This appears to have been be planned by the linux emulator team |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| // @TODO: Ask if there is a better way for this.. | ||
| // We need to update projection bindings in the subquery shaper to relate to a query expression that can actually provide the correct binding information. | ||
| // Then we are able to use the projection binding's query expression directly in ShaperProcessingVisitor, instead of storing the select expression separately there | ||
| // This is needed because cosmos can have projections which are subqueries, and those subqueries can have their own projections | ||
| // This appears to be needed because ShapedQueryExpression doesn't properly replace projection bindings their query expression when updating the shaper expression. | ||
| // But fixing that causes a lot of errors (in other providers?). | ||
| new ProjectionBindingQueryProjectionApplyingExpressionVisitor().Visit(subquery.ShaperExpression); |
There was a problem hiding this comment.
@AndriySvyryd I forgot to point this out
The current ShaperProcessingVisitor for cosmos will directly use the ProjectionBindingExpression.QueryExpression to find the ProjectionExpression for a ProjectionBindingExpression. This is to be able to generate shapers for subqueries in projections. This is different from relational where only the SelectExpression from the final ShapedQueryExpression is used, but relational doesn't have subqueries in projections AFAIK.
What I found odd is that I don't think this code would be needed if ShapedQueryExpression.UpdateQueryExpression actually replaced the ProjectionBindingExpression.QueryExpression of any ProjectionBindingExpressions it found in the ShaperExpression, which it does look like it intends to. However, fixing that did cause a lot of errors in other providers.
Do you find this current fix acceptable?
Part of: #34567
Implements: #34067
Fixes: #38138 , #31696