apache / apache/datafusion-sqlparser-rs
Parse negative numbers for Postgres Dialect
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
Parser should parse negative numbers as is, rather than into a unary_op neg, wrapping an inner value, to be consistent with Postgres.
Postgres behaviour using (pglast):
```
[nix-shell:~/projects/risingwave-nix]$ ./query_parser.py "select -(-(-(9223372036854775808)))"
{'@': 'SelectStmt',
'all': False,
'limitOption': {'#': 'LimitOption',
'name': 'LIMIT_OPTION_DEFAULT',
'value': 0},
'op': {'#': 'SetOperation', 'name': 'SETOP_NONE', 'value': 0},
'targetList': ({'@': 'ResTarget',
'location': 7,
'val': {'@': 'A_Const',
'location': 7,
'val': {'@': 'Float',
'val': Decimal('-9223372036854775808')}}},)}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the nested-negative example through the Postgres dialect, using the query_parser.py entry point shown in the issue. Trace how negative numeric literals are represented in the parser output; done means they match the shown Postgres behavior as numeric constants rather than unary_op nodes, with relevant parser coverage added or updated once located.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100