apache / apache/datafusion-sqlparser-rs

tokenizer is not case-sensitive for keyword determination

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

描述

Consider the following valid SQL statement:
`UPDATE machine_boards21
SET type = 'hybrid', model = 'LX21'
WHERE id = 'machine1';`

tokenizing produces the following output:
`Word(Word { value: "UPDATE", quote_style: None, keyword: UPDATE }), Whitespace(Space), Word(Word { value: "machine_boards21", quote_style: None, keyword: NoKeyword }), Whitespace(Newline), Word(Word { value: "SET", quote_style: None, keyword: SET }), Whitespace(Space), Word(Word { value: "type", quote_style: None, keyword: TYPE }), Whitespace(Space), Eq, Whitespace(Space), SingleQuotedString("hybrid"), Comma, Whitespace(Space), Word(Word { value: "model", quote_style: None, keyword: NoKeyword }), Whitespace(Space), Eq, Whitespace(Space), SingleQuotedString("LG"), Whitespace(Newline), Word(Word { value: "WHERE", quote_style: None, keyword: WHERE }), Whitespace(Space), Word(Word { value: "id", quote_style: None, keyword: NoKeyword }), Whitespace(Space), Eq, Whitespace(Space), SingleQuotedString("machine1"), SemiColon]`

notice how the 'type' token was interpreted: `Word(Word { value: "type", quote_style: None, keyword: TYPE })`

keyword TYPE... This causes an issue in `parse_assignments()` when `parse_identifiers_non_keywords()` is called

The error ultimately thrown by `calling parse_statement()` on this statement is as follows:
`ParserError("Expected =, found: type")`

贡献指南

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

调研方向

复现 issue 中的 SQL 语句并检查 parse_assignments(),尤其是对 parse_identifiers_non_keywords() 的调用。跟踪 tokenizer 如何将关键字 TYPE 分配给未加引号的 type token;完成的标准是该语句能够成功解析,且不会将该标识符视为关键字。

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

评估

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

把新 issue 发到你的邮箱

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