Title: Reserved keywords per dialect · Issue #2786 · JSQLParser/JSqlParser · GitHub
Open Graph Title: Reserved keywords per dialect · Issue #2786 · JSQLParser/JSqlParser
X Title: Reserved keywords per dialect · Issue #2786 · JSQLParser/JSqlParser
Description: Problem Reserved keywords are global. Every token outside NonReservedWord() is reserved for every dialect, so a keyword added for one dialect's syntax becomes unusable as a name everywhere: ClickHouse's PREWHERE and SETTINGS, Exasol's FI...
Open Graph Description: Problem Reserved keywords are global. Every token outside NonReservedWord() is reserved for every dialect, so a keyword added for one dialect's syntax becomes unusable as a name everywhere: ClickHo...
X Description: Problem Reserved keywords are global. Every token outside NonReservedWord() is reserved for every dialect, so a keyword added for one dialect's syntax becomes unusable as a name everywhere: Cli...
Opengraph URL: https://github.com/JSQLParser/JSqlParser/issues/2786
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reserved keywords per dialect","articleBody":"## Problem\n\nReserved keywords are global. Every token outside `NonReservedWord()` is reserved for every dialect, so a keyword added for one dialect's syntax becomes unusable as a name everywhere:\n\n- ClickHouse's `PREWHERE` and `SETTINGS`, Exasol's `FILE`, `SCRIPT`, `CSV`, `FBV` and `VERIFY`, MySQL's `XOR` and `DISTINCTROW`, Oracle's `MINUS`, Salesforce's `INCLUDES`/`EXCLUDES` ...\n- DuckDB does not know any of these words; queries routinely use them as column names (`settings`, `file`, `script`, ...).\n\n`withDialect(...)` cannot help today: it only sets lexer features and a few semantic checks, and reservation is decided by the token range (`MIN_NON_RESERVED_WORD` ... `MAX_NON_RESERVED_WORD`).\n\nMaking each such word non-reserved globally is not an option either: in ClickHouse `FROM t PREWHERE ...` must stay a clause, not an alias.\n\n## Proposal\n\nLet each `Dialect` own its reserved-keyword rules, in both directions, with today's global rules as the default:\n\n1. `KeywordPolicy#isName(word, position)`: whether a word is an unquoted name at a position (object name, function name, label after `AS` or `.`, bare alias), since databases reserve keywords differently in each (PostgreSQL's categories, used by DuckDB, are the reference).\n2. `Dialect#getKeywordPolicy()`: `null` keeps the default rules.\n3. The parser consults the policy wherever it decides \"is this a name?\", rejecting what the dialect reserves and accepting what it does not; constructs led by such words step aside when the word is a name.\n\nTo keep JavaCC's FIRST sets clean, keywords are accepted through dedicated productions behind semantic lookaheads, and words consumed by a syntactic lookahead before any name (MySQL's SELECT modifiers) stay as they are.\n\n## Possible follow-ups\n\n- Generated `keywords.rst` per dialect.\n- Sets for other dialects (PostgreSQL's reserved list, BigQuery's, ...).\n\n#2787 implements it for DuckDB, checked against what DuckDB itself parses for each of its 489 keywords.\n","author":{"url":"https://github.com/guizmaii","@type":"Person","name":"guizmaii"},"datePublished":"2026-10-13T04:20:44Z","url":"https://github.com/JSQLParser/JSqlParser/issues/2786"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b8e7043-c88c-096a-50fb-3cd17294717a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A10:9D17A:39CFB4:4DC322:6B0489EE |
| html-safe-nonce | c58ff1010aa5c4e4f72afa4929a0f61382d9a6e3195cfd53ba78a0634e0d3a92 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTEwOjlEMTdBOjM5Q0ZCNDo0REMzMjI6NkIwNDg5RUUiLCJ2aXNpdG9yX2lkIjoiMjc1NjEyMTA2ODcxOTg2ODM5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0da08bb4f45651173128ab42642d1bed8d1ce1ae23fa8394110f87328462a51d |
| hovercard-subject-tag | issue:5824458194 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JSQLParser/JSqlParser/2786/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fc4ac0d2db2e974b4803fa712f1937606ad22e2d4663df7a0d5a827faac19e5a/JSQLParser/JSqlParser/issues/2786 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fc4ac0d2db2e974b4803fa712f1937606ad22e2d4663df7a0d5a827faac19e5a/JSQLParser/JSqlParser/issues/2786 |
| og:image:alt | Problem Reserved keywords are global. Every token outside NonReservedWord() is reserved for every dialect, so a keyword added for one dialect's syntax becomes unusable as a name everywhere: ClickHo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | guizmaii |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d5c152376e38b7d2e37f3d5179be29a73bee93b85110da28a4eebe1159cdc70 |
| turbo-cache-control | no-preview |
| go-import | github.com/JSQLParser/JSqlParser git https://github.com/JSQLParser/JSqlParser.git |
| octolytics-dimension-user_id | 4643847 |
| octolytics-dimension-user_login | JSQLParser |
| octolytics-dimension-repository_id | 1944709 |
| octolytics-dimension-repository_nwo | JSQLParser/JSqlParser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1944709 |
| octolytics-dimension-repository_network_root_nwo | JSQLParser/JSqlParser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f5017e8ff4ea25a8011fcf0f2a0e430c60dc86c8 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width