fix(parser): allow reserved keywords as aliases after AS - #24503
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
470fe9f to
c06f250
Compare
…n#24410) Treat ROWS, CURRENT_TIME, CURRENT_TIMESTAMP, LOCALTIME, and LOCALTIMESTAMP as identifiers when they follow AS in the lexer. This lets statements like SELECT 1 AS rows and SELECT NOW() AS current_time parse successfully, matching MySQL behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
c06f250 to
79be7fe
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Looks good to me. I pulled the latest head, re-checked the lexer change against the current main base, and did not find a blocker. The allowlist is intentionally narrow, the AS-context rewrite only applies to the five reserved tokens needed for issue #24410, and it does not interfere with their original keyword uses like CURRENT_TIME() or ROWS in window frames. The added parser tests and the parser package test suite both look good for this fix.
What type of PR is this?
Which issue(s) this PR fixes:
issue #24410
What this PR does / why we need it:
Allows reserved keywords (
ROWS,CURRENT_TIME,CURRENT_TIMESTAMP,LOCALTIME,LOCALTIMESTAMP) to be used as column aliases afterAS, matching MySQL behavior.Before this fix:
After:
Implementation
Lexer-level fix in
mysql_lexer.go: tracklastTokenand convert the 5 reserved keyword tokens toIDwhen they immediately followAS. No grammar changes needed.Scope
This PR addresses sub-issue 1 of #24410 (reserved word aliases). Sub-issues 2 and 3 (TIMESTAMPDIFF units and aggregate-in-TIMESTAMPDIFF) were already fixed by #23161 (Dec 2025).
Test plan
ROWS(window functions) andCURRENT_TIME()(function call) behavior unchanged🤖 Generated with Claude Code