Repository navigation
fix: bigquery throws on if as first argument - #2959
Open
harryfoster2006 wants to merge 1 commit into
Open
harryfoster2006 wants to merge 1 commit into
harryfoster2006 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In BigQuery,
IFas the first element of an array literal inside a function call fails to parse:Encountered: "[" / "[", at line 2, column 35
Was expecting one of:
<K_RESPECT>,<K_HAVING>,<K_IGNORE>,<K_LIMIT>,<CLOSING_BRACKET>...The same statement parses when
IFisn't the first element, e.g.UNNEST(['a', IF(...)]).Cause
IF is a reserved keyword, so RelObjectName only accepts it as a function name when isReservedKeywordAsIdentifier() allows it. That guard checks the previous token, and [ was not in its list of delimiters that start an expression position (., ,, :, (, =, operators). [ fell through to isReservedKeywordSafeByFollower(), which rejects IF when followed by (.
InternalFunction uses a syntactic LOOKAHEAD(2) to decide whether to enter its argument list. That probe runs the guard, so it failed, the whole optional argument block was skipped, and the parser then hit [ where it expected ). With , before IF the guard already returned true, which is why only the first-element case failed.