-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: complete after error syntax #334
Open
liuxy0551
wants to merge
3
commits into
DTStack:next
Choose a base branch
from
liuxy0551:feat_complete
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
liuxy0551
force-pushed
the
feat_complete
branch
2 times, most recently
from
July 30, 2024 16:41
f6b1a3d
to
56e4d0d
Compare
过程中遇到的问题尝试过以独立语句开头的关键词(如:
REVOKE SELECT (co_name) ON table_name |FROM PUBLIC;
GRANT SELECT (column_name) ON table_name TO |role_specification;
MERGE INTO wines w USING wine_stock_changes s ON s.winename = w.winename
WHEN NOT MATCHED AND stock_delta > 0
THEN INSERT (col_name) |VALUES(s.winename, s.stock_delta);
WITH with_query_name (col_name) AS (SELECT id FROM table_expression) SEARCH DEPTH
FIRST BY column_name SET column_name
CYCLE col_name SET col_name
USING col_name SELECT|; 上述语法中的
SELECT c.customer_id, c.customer_name, c.email, total_orders.total_amount, total_orders.order_count
FROM customers c
JOIN (
SELECT o.customer_id, SUM(o.total_amount) AS total_amount, COUNT(o.order_id) AS order_count
FROM orders o
WHERE o.order_date BETWEEN '2024-08-01' AND '2024-08-31'
GROUP BY o.customer_id
HAVING COUNT(o.order_id) > 5
) AS total_orders
ON c.customer_id = total_orders.customer_id
WHERE| c.status = 'active'
ORDER BY total_orders.total_amount DESC; 上述语句中存在多层级的子查询,此时如果在子查询后出现光标,且光标位置和子查询不是同一层级,那么会出现较为明显的切分错误,结果如下,连子查询的括号都不完整,更不谈正确进行自动补全了。 SELECT o.customer_id, SUM(o.total_amount) AS total_amount, COUNT(o.order_id) AS order_count
FROM orders o
WHERE o.order_date BETWEEN '2024-08-01' AND '2024-08-31'
GROUP BY o.customer_id
HAVING COUNT(o.order_id) > 5
) AS total_orders
ON c.customer_id = total_orders.customer_id
WHERE| 因此,放弃通过以独立语句开头的关键词进行切分,仅通过分隔符进行切分(通常是 |
liuxy0551
force-pushed
the
feat_complete
branch
2 times, most recently
from
August 26, 2024 08:54
b610cb3
to
d841e3c
Compare
liuxy0551
force-pushed
the
feat_complete
branch
8 times, most recently
from
September 27, 2024 07:57
944a97f
to
417c063
Compare
liuxy0551
changed the title
test: complete after error syntax
feat: complete after error syntax
Sep 27, 2024
已发 beta 包在离线中验证效果符合预期, |
HaydenOrz
reviewed
Oct 15, 2024
liuxy0551
force-pushed
the
feat_complete
branch
2 times, most recently
from
October 15, 2024 14:14
9ce9722
to
6cebe8e
Compare
HaydenOrz
reviewed
Oct 22, 2024
liuxy0551
force-pushed
the
feat_complete
branch
from
October 22, 2024 08:40
6cebe8e
to
c031b24
Compare
liuxy0551
force-pushed
the
feat_complete
branch
from
November 7, 2024 10:58
c031b24
to
f2b72ed
Compare
liuxy0551
force-pushed
the
feat_complete
branch
from
November 19, 2024 02:47
f2b72ed
to
de3b760
Compare
所以左右边界都是采取分号来做划分吗? |
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.
在错误语法的 SQL 后进行自动补全
现状举例
预期举例
改动思路
提到的左边界和右边界可以参考 dt-sql-parser #231 的描述。
通过分隔符进行切分(通常是
;
),这里依旧保留现状寻找最小合适范围的策略,并在此策略上继续优化,借助两种方式进一步缩小解析范围。实现效果