apache / apache/datafusion-sqlparser-rs
Cannot parse named windows with modifiers
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 772
- 平均合并
- 4 天 9 小时
- 30 天内合并 PR
- 17
描述
sqlparser-rs only supports named windows that are an identifier. This is fine for queries like:
```sql
SELECT sum(salary) OVER w, avg(salary) OVER w
FROM empsalary
WINDOW w AS (PARTITION BY depname ORDER BY salary DESC);
```
However, it is insufficient for queries in at least BigQuery and MySQL where modifiers can be added to the named window in the OVER clause.
[MySQL named window example](https://dev.mysql.com/doc/refman/8.0/en/window-functions-named-windows.html)
```sql
SELECT
DISTINCT year, country,
FIRST_VALUE(year) OVER (w ORDER BY year ASC) AS first,
FIRST_VALUE(year) OVER (w ORDER BY year DESC) AS last
FROM sales
WINDOW w AS (PARTITION BY country)
```
[BigQuery named window example](https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls)
```sql
SELECT item, purchases, category, LAST_VALUE(item)
OVER (
item_window
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
) AS most_popular
FROM Produce
WINDOW item_window AS (
PARTITION BY category
ORDER BY purchases)
```
This would build upon prior to work:
- https://github.com/sqlparser-rs/sqlparser-rs/issues/867
- https://github.com/sqlparser-rs/sqlparser-rs/pull/881
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先检查 sqlparser-rs 如何解析 OVER 子句中的 named-window 表达式,然后查看 issue #867 和 pull request #881 以了解之前的设计。为 MySQL 和 BigQuery 示例添加解析覆盖,并验证带修饰符的 named windows 能够被接受,同时不会导致普通 named windows 出现回归。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust, sql
- 领域
- compilers, databases
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 40/100