apache / apache/datafusion-sqlparser-rs
Support `COLUMNS(* EXLCUDE(col1, col2))` syntax
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
DuckDB supports excluding columns via this syntax:
```
SELECT COLUMNS(* EXCLUDE(col1, col2)) FROM tbl
```
Currently this format gives a syntax error:
```
Parse error: sql parser error: Expected: ), found: EXCLUDE at Line: 1, Column: 18
```
More details at: https://duckdb.org/docs/stable/sql/expressions/star.html#columns-expression
Note that other modifiers beyond `EXCLUDE` are supported, such as `REPLACE`, `RENAME`, `LIKE` etc, see the syntax diagram at https://duckdb.org/docs/stable/sql/query_syntax/select.html#syntax (click `star-options` on the digram to expand).
This highly suggests that the general solution for this would be to add a new `Expr::Columns` expression enum with parsing logic somewhat similiar to `Expr::MatchAgainst`, and then add logic in `parse_select_item` to support returning a `SelectItem::UnnamedExpr(Expr::Columns)`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at parse_select_item and compare the parsing path for Expr::MatchAgainst. Add support for an Expr::Columns expression returned as SelectItem::UnnamedExpr(Expr::Columns), then verify the documented COLUMNS(* EXCLUDE(...)) form and the listed REPLACE, RENAME, and LIKE modifiers parse successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100