apache / datafusion-sqlparser-rs

Extensible SQL Lexer and Parser for Rust
Apache License 2.0
2.81k stars 543 forks source link

ANTI join without `LEFT/RIGHT` creates an invalid AST. #1504

Closed universalmind303 closed 1 week ago

universalmind303 commented 2 weeks ago

if you try to do a ANTI JOIN without <LEFT|RIGHT> ANTI, it treats ANTI as an alias for the table instead of an anti join

example query. This works fine in duckdb.

        SELECT * from table1
        ANTI JOIN table2 t2 on t1.id = t2.id 

Full Example.

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

fn main() {
    let sql = r#"
        SELECT * from table1
        ANTI JOIN table2 t2 on t1.id = t2.id 
        "#;

    let dialect = GenericDialect {};

    let ast = Parser::parse_sql(&dialect, sql).unwrap();

    println!("AST: {:?}", ast);
}