apache / apache/datafusion-sqlparser-rs

Unable to parse 'max' for optional precision column with MS Sql dialect

Open
#1,714 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 following is a valid MS Sql query, but cannot ne parsed due to the `varbinary` implementation.

Variable character-based columns, `nvarchar` and `varchar`, use a union type `CharacterLength` type that allows for either `IntegerLength` or `Max` values. The `varbinary` implementation needs a similar union, such as `BinaryLength` (reusing `CharacterLength` seems to have a naming mismatch).

```
#[test]
fn parse_ms_sql_varbinary_max(){
let sql = "CREATE TABLE example(VarBinaryMaxCol varbinary(max) not null);";
let parsed = ms().parse_sql_statements(sql);

assert!(parsed.is_ok());
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the varbinary implementation and compare it with the CharacterLength handling described in the issue. Run the provided parse_ms_sql_varbinary_max test; done means the MS SQL CREATE TABLE statement with varbinary(max) parses successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.