apache / apache/datafusion-sqlparser-rs

Cannot parse named windows with modifiers

未關閉
#999 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
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

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。