apache / apache/datafusion-sqlparser-rs

Can't parse jsonb extractions in an on conflict in Postgres

Open
#1,977 0 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

The parser does not support the following:

```sql
INSERT INTO table_with_constraint_over_jsonb (a_number, a_jsonb, a_string)
VALUES ($1, $2, $3)
ON CONFLICT (a_number, (a_jsonb->>'name'))
DO UPDATE SET a_string = EXCLUDED.a_string
RETURNING *;
```

It errors on the `(a_jsonb->>'name')` part with the error: `ParserError("Expected: identifier, found: ( at Line: 1, Column: 119")`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the parser error with the SQL statement in the issue, focusing on the parenthesized jsonb extraction in the ON CONFLICT target. Trace the SQL parser's handling of ON CONFLICT expressions, then verify that this statement parses successfully without regressing other conflict targets.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.