fix(mssql): support LEFT/RIGHT and niladic keyword functions in expressions#321
Open
rebelice wants to merge 1 commit into
Open
fix(mssql): support LEFT/RIGHT and niladic keyword functions in expressions#321rebelice wants to merge 1 commit into
rebelice wants to merge 1 commit into
Conversation
…d functions
Add parsePrimary() cases for CoreKeyword tokens that are legally callable
in expression position:
- kwLEFT, kwRIGHT: dispatch to parseIdentExpr() when followed by '(',
enabling LEFT(str,n)/RIGHT(str,n) scalar calls (BYT-9747). LEFT/RIGHT
JOIN handling in matchJoinType() is unaffected.
- kwCURRENT_TIMESTAMP, kwCURRENT_USER, kwSESSION_USER, kwSYSTEM_USER,
kwUSER, kwCURRENT_DATE, kwCURRENT_TIME: parsed as niladic FuncCallExpr
via parseNiladicKeywordFunc(). These SQL-standard functions take no
parentheses; KEYWORD() is correctly rejected.
Extend callableKeywordManifest with 9 entries (2 roleExprScalar +
7 roleNiladic) and add a niladic-with-empty-parens reject context.
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.
Summary
parsePrimary()cases for 9 CoreKeyword tokens that are legally callable in expression positionparseIdentExpr()when followed by(, enablingLEFT(str, n)/RIGHT(str, n)scalar calls.LEFT/RIGHT JOINhandling inmatchJoinType()is unaffected.CURRENT_TIMESTAMP,CURRENT_USER,SESSION_USER,SYSTEM_USER,USER,CURRENT_DATE,CURRENT_TIME— parsed asFuncCallExprwithout parentheses viaparseNiladicKeywordFunc().KEYWORD()with parens is correctly rejected.callableKeywordManifestwith 9 entries (2roleExprScalar+ 7roleNiladic) and addniladic-with-empty-parensreject context.Fixes BYT-9747.
Test plan
TestCallableKeywordManifest— all 29 entries pass (accept contexts)TestCallableKeywordRoleRejection— all rejection contexts pass including newniladic-with-empty-parensTestCallableKeywordManifestIsExhaustive— passesSELECT LEFT('abc', 2),SELECT RIGHT('abc', 2),SELECT CURRENT_TIMESTAMP,SELECT CURRENT_USERall parse correctlyLEFT JOIN,RIGHT OUTER JOIN,CREATE PARTITION FUNCTION ... RANGE LEFT/RIGHT,CREATE USERunaffectedSELECT CURRENT_TIMESTAMP()andSELECT CURRENT_USER()correctly fail