Fix compiler crash with nested queries in select as a field #43355
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.
Purpose
Fixes #43336
Approach
The
identifiers
map in theQueryDesugar
stores a set of identifiers and their symbols found in the lambda function created for clauses inside the query. When anidentifier
in aselect
clause is first used in a nested query or within a lambda function in a query, the symbol of thatidentifier
is marked as aclosure
symbol. For consequent usages of this identifier in the select clause this symbol that has been marked as a closure should be used (i.e. for other fields in the select clause).Consider the above code. The student identifier inside the select clause is marked as a closure variable first because it is used within a nested query as in the first field. The second field also uses this student identifier and the variable of this second usage should also refer to the Symbol that is marked as a closure because of that nested field.
The current implementation restricts to using symbols of the identifiers from this
identifiers
map when either on in a nestedQuery or within an arrow function. This fix removes that check usage.Samples
Remarks
Check List