feat: optimize collecting entity when match empty column in entityCollecting context[05.15]#467
Open
Cythia828 wants to merge 1 commit into
Open
feat: optimize collecting entity when match empty column in entityCollecting context[05.15]#467Cythia828 wants to merge 1 commit into
Cythia828 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解决问题
在 #457 的基础上继续解决,目前已支持各大方言派生表、子查询、查询结果的字段实体收集,在语法不完整时保证了语法树完整性。
Preview地址
https://cythia828.github.io/monaco-sql-languages/
修改内容
该 commit 对 7 个方言(MySQL、PGSQL、Flink、Spark、Hive、Impala、Trino)的实体收集功能做了统一增强,核心目的是:在语法不完整时,通过语义谓词 shouldMatchEmpty() 匹配空列,保证语法树完整性,使实体收集能正常工作。
修改逻辑
补充/更新各方言的 suggestionWithEntity.test.ts 用例,覆盖空列补全、带逗号空列补全、isContainCaret 语义、uid DOT 模式等场景。
为什么这样修改
问题 原因 解决方式
目前剩余问题
PGSQL在某些语法不完整的情况下不报错:

select from tb1PGSQL 不报错的原因分析
根因:sqlExpression 中的 targetList? 被设计为可选(?),目的是兼容以下合法 PG 语法:
如果将
targetList?改为targetList必选,以上三种合法语法都会报错。完整链路:
simpleSelect: KW_SELECT (KW_ALL? intoClause? | distinctClause?) sqlExpressionsqlExpression: targetList? intoClause? fromClause? ...对于
select from t1:要彻底修复需要重构 simpleSelect,将 SELECT INTO 和 SELECT 分拆为独立分支,但这涉及大量语法改动,风险较高。当前保持原状,所有测试通过。