Ensure function aliases allow retrying queries #54824
Merged
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.
Based on #54823 to avoid merge conflicts because they touch the same test
Motivation / Background
Previously, function aliases (ex. combining a
#group
and#count
)would make queries non-retryable because
Function#as
would always wrapa given alias in a non-retryable
SqlLiteral
.Detail
This could be addressed by making
Function#as
behave similarly toAliasPredication
(retry everything). However,Function#as
can alsojust be removed so that
Function
usesAliasPredication#as
instead.This behaves slightly differently because
AliasPredication#as
will nowreturn the
Function
wrapped in anAlias
(meaning the return valuemust be used). Only a single place in Active Record needed to be changed
and all others already did the correct thing.
Additional information
This also resolves a long standing FIXME suggesting removing the custom
Function#as
in favor of usingAlias
nodes. The other half of thecomment suggesting
Function
could inherit fromUnary
does not makesense because SQL functions could potentially take multiple parameters,
so the existing superclass should not be changed.
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]