Skip to content

Generic: Keep clause keywords usable as unquoted column and table names - #3088

Open
blaginin wants to merge 1 commit into
apache:mainfrom
blaginin:db/generic-keyword-identifiers
Open

blaginin wants to merge 1 commit into
apache:mainfrom
blaginin:db/generic-keyword-identifiers

Conversation

@blaginin

@blaginin blaginin commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

#3004 (comment)

Query 0.63 RC
select offset from (select 42 as "offset") 42 ParserError: Expected: ), found: 42
select union from (select 42 as "union") 42 one empty row, no error
with limit as (select 42 as x) select * from limit 42 ParserError: Expected: table name, found: limit

@blaginin
blaginin marked this pull request as ready for review December 1, 2026 22:33
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.66%. Comparing base (20a8c47) to head (0c44ef1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3088   +/-   ##
=======================================
  Coverage   83.65%   83.66%           
=======================================
  Files          42       42           
  Lines       35837    35849   +12     
  Branches    35837    35849   +12     
=======================================
+ Hits        29980    29993   +13     
  Misses       2418     2418           
+ Partials     3439     3438    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94 LucaCappelletti94 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do search for other keywords which should not be allowed as unquoted columns and add red tests for them to avoid other future regressions.

Comment thread src/dialect/generic.rs
Comment on lines +238 to +241
/// The generic dialect reserves no keyword as a table name.
fn is_table_factor(&self, _kw: &Keyword, _parser: &mut Parser) -> bool {
true
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenericDialect::is_table_factor returning true for every keyword also unreserves ON, which #2633 reserved on purpose, and I thought I had added red tests for it but I must have been mistaken. Please do check well whether other such keywords should be included in the method.

Suggested change
/// The generic dialect reserves no keyword as a table name.
fn is_table_factor(&self, _kw: &Keyword, _parser: &mut Parser) -> bool {
true
}
/// The generic dialect reserves only `ON` as a table name.
fn is_table_factor(&self, kw: &Keyword, _parser: &mut Parser) -> bool {
*kw != Keyword::ON
}

Comment thread tests/sqlparser_common.rs
#[test]
fn parse_generic_reserved_keyword_as_table_name() {
let generic = TestedDialects::new(vec![Box::new(GenericDialect {})]);
for keyword in ["into", "limit", "having", "where", "on"] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for keyword in ["into", "limit", "having", "where", "on"] {
for keyword in ["into", "limit", "having", "where"] {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants