apache / apache/datafusion-sqlparser-rs

SQL is parsed incorrectly when `trailing_commas` is not set

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

描述

When parser not set `trailing_commas=true` in `ParserOptions` or use `BigQueryDialect`, the following SQL will be wrongly parse instead of throw an error.

```sql
SELECT foo, bar, FROM baz

-- Will be wrongly parse instead of throw an error.

SELECT foo, bar, FROM AS baz
```

In theory it should throw a error

relevant code

```rust
#[test]
fn parse_range_select() {
let statements = Parser::parse_sql(&GenericDialect {}, "SELECT foo, bar, FROM baz").unwrap();
println!("{}", statements[0]);
}
```

贡献指南

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

调研方向

从 parse_range_select 示例中的 Parser::parse_sql 调用开始,检查 trailing_commas 未设置时 GenericDialect 如何处理 SELECT 列表。添加一个涵盖所示查询的回归测试:拒绝带有尾随逗号的格式错误语法,同时继续支持已配置的 trailing_commas 行为。

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

评估

技术栈
rust
领域
compilers
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

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