apache / apache/datafusion-sqlparser-rs
INSERT from SELECT cannot be parsed with an ON CONFLICT clause
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
Parsing the following SQL
```sql
INSERT INTO foo
SELECT 1, 'data'
ON CONFLICT DO NOTHING
```
fails with
```
Expected: end of statement, found: CONFLICT at Line: 3, Column: 6
```
both for Generic and PostgreSQL dialects.
However, at least in PostgreSQL it seems to be a valid construct, equivalent to
```sql
INSERT INTO foo
(SELECT 1, 'data')
ON CONFLICT DO NOTHING
```
(this one is parsed by `sqlparser` correctly).
The same query without the "ON CONFLICT" clause can be successfully parsed too.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the supplied INSERT ... SELECT ... ON CONFLICT query through the SQL parser, checking both Generic and PostgreSQL dialects and comparing it with the parenthesized form. Trace the INSERT statement parsing entry point and confirm that the unparenthesized form is accepted while existing cases remain valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100