apache / apache/datafusion-sqlparser-rs
Nested type modifiers/complex type
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
Example Trino SQL:
```sql
SELECT
row_id,
array_agg(
CAST(
ROW(
total_amount
)
AS
ROW(
total_amount Decimal(14,2)
)
)
ORDER BY payment_requested_date DESC
) AS payment_request_details
FROM
iceberg.my_table_name
GROUP BY 1
```
This throws an error when using `GenericDialect`, specifically when it tries to parse `Decimal(14,2)`: ```ParserError("Expected: type modifiers, found: ( at Line: 10, Column: 37")```
Stepping through the code it looks like this is because it does not support deeply nested definitions because `parse_optional_type_modifiers` does not allow `Token::LParen`.
This may be by design, but it may break parsing when you get to really complex queries (e.g. deeply nested rows).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at GenericDialect's handling of nested type definitions and parse_optional_type_modifiers, then reproduce the supplied query to confirm the Decimal(14,2) failure. Trace how nested ROW types are parsed and add regression coverage showing that the query parses successfully with its nested type modifiers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- compilers, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100