Skip to content

Regression: Decreased tolerance to column names matching SQL keywords #2049

@sergiimk

Description

@sergiimk

Related to: apache/datafusion#17802

Between versions 0.57.0 and 0.58.0 there appears to be a regression that decreased parser tolerance to column names that collide with SQL keywords.

Example:

use sqlparser::dialect::GenericDialect;
use sqlparser::parser::Parser;

fn main() {
    let dialect = GenericDialect {}; // or AnsiDialect

    let sql = r#"
        SELECT
            'a' as a,
            offset
        FROM my_table
    "#;

    let ast = Parser::parse_sql(&dialect, sql).unwrap();
    println!("AST: {:#?}", ast);
}

This works on version 0.57.0, but fails on 0.58.0 with error:

ParserError("Expected: end of statement, found: my_table at Line: 5, Column: 14")

These queries work fine, which adds some confusing inconsistency into the mix:

SELECT
    offset
FROM my_table
SELECT
    offset,
    'a' as a
FROM my_table

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions