feat: Allow OUTER keyword as function parameter name #2021
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.
Context
SQL keywords are sometimes allowed as parameter names in table functions. For example, the following statement is valid on Snowflake:
Note that the second named parameter passed to the table function
flatten
isouter
, which is a SQL keyword, and it is unquoted.Currently, statements like this fail to parse, I think because SQL keywords are not allowed as parameter names. However, as this is a valid statement, I'd like to be able to parse it.
Details
The production in the grammar which handles named parameters is
OracleNamedFunctionParameter
. Currently, this is using theRelObjectNameExt2
production to match the parameter name. I think (although I don't understand how) this does not match keywords. Since parameter names are not objects, I thought we could use the<S_IDENTIFIER>
token, which looks like it should match something likeouter
. However, this doesn't appear to match keywords, again I don't understand how - looking at the<S_IDENTIFIER>
token, it looks like it will match any sequence of unicode characters 🤔 . As a simple (probably wrong) solution, I've manually added the<K_OUTER>
token as a possible match inOracleNamedFunctionParameter
:But this feels wrong. I don't think parameter names necessarily need to be valid object names, hence why I wanted to use
<S_IDENTIFIER>
, but I can't work out why<S_IDENTIFIER>
won't match keywords. Happy to discuss this further, any help would be much appreciated!