Support parsing SQL Server SELECT Person1.name sql
Background
Hi community. This issue is for #29149.
The ShardingSphere SQL parser engine helps users to parse SQL to create the AST (Abstract Syntax Tree) and visit the AST to get SQLStatement (Java Object). Currently, we are planning to enhance the support for SQL Server SQL parsing in ShardingSphere.
More details: https://shardingsphere.apache.org/document/current/en/reference/sharding/parse/
Task
This issue is to support more SQL Server sql parsing, as follows:
SELECT
Person1.name AS PersonName,
STRING_AGG(Person2.name, '->') WITHIN GROUP (GRAPH PATH) AS Friends
FROM
Person AS Person1,
friendOf FOR PATH AS fo,
Person FOR PATH AS Person2
WHERE MATCH(SHORTEST_PATH(Person1(-(fo)->Person2)+))
AND Person1.name = 'Jacob'
SELECT PersonName, Friends, levels
FROM (
SELECT
Person1.name AS PersonName,
STRING_AGG(Person2.name, '->') WITHIN GROUP (GRAPH PATH) AS Friends,
LAST_VALUE(Person2.name) WITHIN GROUP (GRAPH PATH) AS LastNode,
COUNT(Person2.name) WITHIN GROUP (GRAPH PATH) AS levels
FROM
Person AS Person1,
friendOf FOR PATH AS fo,
Person FOR PATH AS Person2
WHERE MATCH(SHORTEST_PATH(Person1(-(fo)->Person2)+))
AND Person1.name = 'Jacob'
) AS Q
WHERE Q.LastNode = 'Alice'
SELECT
Person1.name AS PersonName,
STRING_AGG(Person2.name, '->') WITHIN GROUP (GRAPH PATH) AS Friends
FROM
Person AS Person1,
friendOf FOR PATH AS fo,
Person FOR PATH AS Person2
WHERE MATCH(SHORTEST_PATH(Person1(-(fo)->Person2){1,3}))
AND Person1.name = 'Jacob'
SELECT PersonName, Friends
FROM (
SELECT
Person1.name AS PersonName,
STRING_AGG(Person2.name, '->') WITHIN GROUP (GRAPH PATH) AS Friends,
COUNT(Person2.name) WITHIN GROUP (GRAPH PATH) AS levels
FROM
Person AS Person1,
friendOf FOR PATH AS fo,
Person FOR PATH AS Person2
WHERE MATCH(SHORTEST_PATH(Person1(-(fo)->Person2){1,3}))
AND Person1.name = 'Jacob'
) Q
WHERE Q.levels = 2
SELECT
Person1.name AS PersonName,
STRING_AGG(Person2.name, '->') WITHIN GROUP (GRAPH PATH) AS Friends,
Restaurant.name
FROM
Person AS Person1,
friendOf FOR PATH AS fo,
Person FOR PATH AS Person2,
likes,
Restaurant
WHERE MATCH(SHORTEST_PATH(Person1(-(fo)->Person2){1,3}) AND LAST_NODE(Person2)-(likes)->Restaurant )
AND Person1.name = 'Jacob'
AND Restaurant.name = 'Ginger and Spice'
Process
- First confirm that this is a correct
SQL Serversql syntax, if not please leave a message under the issue and ignore it; - Compare SQL definitions in Official SQL Doc and ShardingSphere SQL Doc;
- If there is any difference in ShardingSphere SQL Doc, please correct them by referring to the Official SQL Doc;
- Run mvn install the current_file_module;
- Check whether there are any exceptions. If indeed, please fix them. (Especially xxxVisitor.class);
- Add new corresponding SQL case in SQL Cases and expected parsed result in Expected Statement XML;
- Run SQLParserParameterizedTest to make sure no exceptions.
Relevant Skills
- Master JAVA language
- Have a basic understanding of Antlr
g4file - Be familiar with
SQL ServerSQLs
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
@FlyingZC Hi community, I will have a try. Please assign me.
@shengdoupi Welcome, I just assign this issue to you.
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
@FlyingZC Please assign this issue to me.
@FlyingZC Please assign this issue to me.
@TherChenYang Hi, I'm working on this issue now. It takes me a long time since graph related syntax is quite complex for me. Anyway, I believe it can be finished in a week, thank you!
Ok, looking forward to your good news @shengdoupi
@FlyingZC Please assign this issue to me.
@TherChenYang Hi, I'm working on this issue now. It takes me a long time since graph related syntax is quite complex for me. Anyway, I believe it can be finished in a week, thank you!
Sorry, I see the issue is in an expired state, so I requested an assignment, look forward to your PR.
@strongduanmu Hi, when I try to submit a PR for this issue, I find the function has been supported in #30288 , I think you can close this issue now.
@shengdoupi Thank you for your test work, I will close this issue.