apache / apache/datafusion-sqlparser-rs
Parser is dropping Inner Joins when constructing the SQL from AST
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
# Problem
A SQL statement with an Inner Join is given to the parser, once converted to AST and getting the result back as a SQL string parser loose the inner join altering original SQL statement.
I know `INNER JOIN` is represented as `JOIN` in many dialects. But since parser alters original query when converted back to AST is a problem as it is loosing information.
**Example:**
```rust
fn main() {
let sql_select = "SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID";
let dialect = MySqlDialect {}; // or AnsiDialect, or your own dialect ...
let mut ast = Parser::parse_sql(&dialect, sql_select).unwrap();
assert_eq!(ast[0].to_string(), sql_select);
}
```
**Output:**
```bash
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `"SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID"`,
right: `"SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID"`', src/main.rs:111:5
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.