You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "TherChenYang (via GitHub)" <gi...@apache.org> on 2024/02/23 11:11:41 UTC
[PR] Support parser SQLServer match grammar [shardingsphere]
TherChenYang opened a new pull request, #30258:
URL: https://github.com/apache/shardingsphere/pull/30258
Fixes #30253.
Changes proposed in this pull request:
- Support the parsing of the match syntax in SQLServer [MATCH (Transact-SQL)](https://learn.microsoft.com/zh-cn/sql/t-sql/queries/match-sql-graph?view=sql-server-ver16)
- Support parsing the syntax of graph agg functions in SQL Server. [SHORTEST_PATH (Transact-SQL)](https://learn.microsoft.com/zh-tw/sql/relational-databases/graphs/sql-graph-shortest-path?view=sql-server-ver16#for-path)
#### GRAPH_PATH_AGGREGATE syntax rules
<img width="646" alt="image" src="https://github.com/apache/shardingsphere/assets/124348939/6c978172-0a55-49dd-bfeb-4ff1939a70f6">
#### Supported SQL cases are as follows
##### case1
``` sql
SELECT Person2.name AS FriendName
FROM Person Person1, friend, Person Person2
WHERE MATCH(Person1-(friend)->Person2)
AND Person1.name = 'Alice';
```
[link](https://learn.microsoft.com/zh-cn/sql/t-sql/queries/match-sql-graph?view=sql-server-ver16)
##### case2
```sql
SELECT Person3.name AS FriendName
FROM Person Person1, friend, Person Person2, friend friend2, Person Person3
WHERE MATCH(Person1-(friend)->Person2-(friend2)->Person3)
AND Person1.name = 'Alice';
```
[link](https://learn.microsoft.com/zh-cn/sql/t-sql/queries/match-sql-graph?view=sql-server-ver16)
##### case3
```sql
SELECT Person1.name AS Friend1, Person2.name AS Friend2
FROM Person Person1, friend friend1, Person Person2,
friend friend2, Person Person0
WHERE MATCH(Person1-(friend1)->Person0 AND Person2-(friend2)->Person0);
```
[link](https://learn.microsoft.com/zh-cn/sql/t-sql/queries/match-sql-graph?view=sql-server-ver16)
##### case4
```sql
SELECT PersonName, Friends
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
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'
```
[link](https://learn.microsoft.com/zh-cn/sql/relational-databases/graphs/sql-graph-shortest-path?view=sql-server-ver16)
##### case5
```sql
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'
```
[link](https://learn.microsoft.com/zh-cn/sql/relational-databases/graphs/sql-graph-shortest-path?view=sql-server-ver16)
##### case6
```sql
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'
```
[link](https://learn.microsoft.com/zh-cn/sql/relational-databases/graphs/sql-graph-shortest-path?view=sql-server-ver16)
---
Before committing this PR, I'm sure that I have checked the following options:
- [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [x] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [x] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [x] I have added corresponding unit tests for my changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parser SQLServer match grammar [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #30258:
URL: https://github.com/apache/shardingsphere/pull/30258
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org