MySQL: Support CAST(... AS ... ARRAY) syntax
#2151
Open
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.
MySQL has a special case in
CASTparsing where the type can be followed byARRAY. This is only used for creating multi-valued indexes in InnoDB, so is only allowed inCREATE TABLEand other DDL statements when specifying keys. See the docs.Given those restrictions, we could be significantly more restrictive in parsing this, e.g. not parsing
ARRAYunless we are in a key specification. Or, if there was such a thing as a suffix array type definition, we could parse it as a type. But as far as I know, that doesn't exist in any supported SQL dialects, and encounteringARRAYhere is unambiguous. So it seemed simplest to be permissive and always parse it. The only downside I can see is we are now adding a field toExpr::Cast.