apache / apache/datafusion-sqlparser-rs

Allow the possibility to optionnaly add "AS" in the From clause for CustomDialect

Open
#1,784 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.5k
Forks
772
Avg merge
4d 9h
Merged PRs (30d)
17

Description

Some dialect like Oracle do not support "AS" in the from clause and failed for some query :

eg that is working or Oracle :
```sql
SELECT SRC.*, SYSDATE AS CopyDate FROM TPCH_IN.ORDERS_FLAT SRC WHERE 1 = 1 AND O_ORDERKEY BETWEEN 100 and 1000
```
whereas this is not working (on Oracle)
```sql
SELECT SRC.*, SYSDATE AS CopyDate FROM TPCH_IN.ORDERS_FLAT AS SRC WHERE 1 = 1 AND O_ORDERKEY BETWEEN 100 and 1000
```

Currently the sqlparser force the addition of the keyword AS between the table and it's alias even the original query does not contains "AS" in its from clause.

I don't see the ability to create a custom dialect to avoid this behavior.

I am not sure but i think the "problem" could be here :
https://github.com/apache/datafusion-sqlparser-rs/blob/62495f2f0d998690495f111063a0b0a3466ffa69/src/ast/query.rs#L662

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/ast/query.rs around line 662 and trace how table aliases are rendered for CustomDialect. Check nearby dialect and rendering tests, then verify that a custom dialect can omit AS in FROM aliases while existing dialect behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.