Skip to content

fix(mssql): support LEFT/RIGHT and niladic keyword functions in expressions#321

Open
rebelice wants to merge 1 commit into
mainfrom
fix-mssql-keyword-callable
Open

fix(mssql): support LEFT/RIGHT and niladic keyword functions in expressions#321
rebelice wants to merge 1 commit into
mainfrom
fix-mssql-keyword-callable

Conversation

@rebelice

Copy link
Copy Markdown
Collaborator

Summary

  • Add parsePrimary() cases for 9 CoreKeyword tokens that are legally callable in expression position
  • LEFT/RIGHT (BYT-9747): dispatch to parseIdentExpr() when followed by (, enabling LEFT(str, n) / RIGHT(str, n) scalar calls. LEFT/RIGHT JOIN handling in matchJoinType() is unaffected.
  • Niladic functions: CURRENT_TIMESTAMP, CURRENT_USER, SESSION_USER, SYSTEM_USER, USER, CURRENT_DATE, CURRENT_TIME — parsed as FuncCallExpr without parentheses via parseNiladicKeywordFunc(). KEYWORD() with parens is correctly rejected.
  • Extend callableKeywordManifest with 9 entries (2 roleExprScalar + 7 roleNiladic) and add niladic-with-empty-parens reject context.

Fixes BYT-9747.

Test plan

  • TestCallableKeywordManifest — all 29 entries pass (accept contexts)
  • TestCallableKeywordRoleRejection — all rejection contexts pass including new niladic-with-empty-parens
  • TestCallableKeywordManifestIsExhaustive — passes
  • Manual verification: SELECT LEFT('abc', 2), SELECT RIGHT('abc', 2), SELECT CURRENT_TIMESTAMP, SELECT CURRENT_USER all parse correctly
  • Regression: LEFT JOIN, RIGHT OUTER JOIN, CREATE PARTITION FUNCTION ... RANGE LEFT/RIGHT, CREATE USER unaffected
  • Reject: SELECT CURRENT_TIMESTAMP() and SELECT CURRENT_USER() correctly fail

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant