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 摘要。