apache / apache/datafusion-sqlparser-rs
Support PostgreSQL json_to_record / jsonb_to_record syntax
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
### Current state:
`PostgreSQL` `json_to_record` / `jsonb_to_record` syntax raises a `ParseError`:
```
use sqlparser::dialect::PostgreSqlDialect;
use sqlparser::parser::Parser;
fn main() {
let sql = r#"select * from json_to_record('{"a":1,"b":[1,2,3],"c":[1,2,3],"e":"bar"}') as x(a int, b text, c int[], d text);"#;
let dialect = PostgreSqlDialect {};
let ast = Parser::parse_sql(&dialect, sql).unwrap();
println!("AST: {:?}", ast);
}
```
### Future state:
`json_to_record` / `jsonb_to_record` syntax supported.
### Additional:
As per [the postgresql docs](https://www.postgresql.org/docs/16/functions-json.html) - search for json_to_record (no deep link)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the SQL example with PostgreSqlDialect and consult the PostgreSQL documentation for json_to_record and jsonb_to_record. Done means both forms parse successfully instead of raising ParseError, including the column definition list shown in the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100