apache / apache/datafusion-sqlparser-rs

[Postgres]: `?` JSON operator cannot be parsed without a space after the field name

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

When using `PostgreSqlDialect`, the question mark cannot be parsed if it is not followed by a space, whereas postgres accepts the query. The following code panics when parsing `broken`:

```rust
fn main() {
let broken = r#"SELECT user?'adress' FROM my_table"#;
let working = r#"SELECT user? 'adress' FROM my_table"#;

let working_parsed =
sqlparser::parser::Parser::parse_sql(&sqlparser::dialect::PostgreSqlDialect {}, working)
.expect("Failed to parse SQL query");
println!("{:?}", working_parsed);

let broken_parsed =
sqlparser::parser::Parser::parse_sql(&sqlparser::dialect::PostgreSqlDialect {}, broken)
.expect("Failed to parse SQL query");
println!("{:?}", broken_parsed);
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied Parser::parse_sql example with PostgreSqlDialect and compare the two query forms. Trace how the parser handles ? beside the field name, then add coverage for both spacing forms and confirm the PostgreSQL JSON operator parses without panic.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.