apache / apache/datafusion-sqlparser-rs

Add Support for Postgres JSON prepared query

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

Description

I am using sqlparser 0.4.0 with rust version 1.36.0
Query:
`
SELECT "emp"."id", "emp"."data" FROM "emp" WHERE id = $1 AND data->>'id'=$2 -- binds: ["emp_name", "123"]
`

Error:
`ParserError("Expected an expression, found: >")`

Dialect Used:
```rust
impl Dialect for MyPostgresSqlDialect {
fn is_identifier_start(&self, ch: char) -> bool {
(ch >= 'a' && ch <= 'z')
|| (ch >= 'A' && ch <= 'Z')
|| (ch == '@')
|| ch == '$'
|| ch == '_'
}

fn is_identifier_part(&self, ch: char) -> bool {
(ch >= 'a' && ch <= 'z')
|| (ch >= 'A' && ch <= 'Z')
|| (ch >= '0' && ch <= '9')
|| (ch == '@')
|| ch == '$'
|| ch == '_'
}
}
```

Even I am adding chars `-` and `>` into `is_identifier_part` then it is giving Error:: `ParserError("Expected end of statement, found: \'id\'")`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported query and error with the PostgreSQL dialect, then inspect how is_identifier_start and is_identifier_part handle the JSON extraction operator and prepared-query placeholders. Done means the query parses successfully without requiring ad hoc identifier characters, with coverage for the shown SQL expression.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.