apache / apache/datafusion-sqlparser-rs

Optional GROUP BY statement

未关闭
#2,056 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
3.5k
派生
772
平均合并
4 天 9 小时
30 天内合并 PR
17

描述

Working on my custom sql validation, I needed somehow to check, does user provide group_by/limit+offset/sort_by clauses.
I got smth like this and found `.group_by` field as non-optional. Is it right?

```rust
let wrong_query = "SELECT * FROM example_table GROUP BY example_field";
//Parser returns success(!) below
if let Statement::Query(q) = Parser::parse_sql(&GenericDialect {}, &query)?.first().unwrap() {
if q.limit_clause.is_none() {...}
if q.order_by.is_none() {...}
let select_query = query.body.as_select().unwrap();
//And I expected smth like this:
if select_query.group_by.is_none() {...}
}

```

Maybe I'm doing smth wrong and there is a proper and faster way for that?
Also I noticed a `parse_optional_group_by` fn but I didn't get how to use it., there is no info nor examples in docs about it. Looks like it's inner fn?

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start by reading the Select.group_by field returned through Parser::parse_sql and the parse_optional_group_by function mentioned in the issue. Determine how the parser represents an absent GROUP BY clause and whether the public API or its documentation needs to expose that distinction; done means the intended behavior is documented or covered by an appropriate parser test.

由索引模型根据 Issue 内容生成。

评估

技术栈
rust, sql
领域
compilers
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。