This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 84a2d427c69 Support parser SQLServer match grammar (#30258)
84a2d427c69 is described below
commit 84a2d427c6984b00de95e60f2ebd6f842444d2d9
Author: LotusMoon <[email protected]>
AuthorDate: Fri Feb 23 21:13:24 2024 +0800
Support parser SQLServer match grammar (#30258)
---
.../src/main/antlr4/imports/sqlserver/BaseRule.g4 | 79 +++-
.../main/antlr4/imports/sqlserver/DMLStatement.g4 | 2 +-
.../antlr4/imports/sqlserver/SQLServerKeyword.g4 | 24 ++
.../statement/SQLServerStatementVisitor.java | 24 ++
.../parser/src/main/resources/case/dml/select.xml | 408 +++++++++++++++++++++
.../main/resources/sql/supported/dml/select.xml | 6 +
6 files changed, 541 insertions(+), 2 deletions(-)
diff --git
a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
index c88652fb6c4..4ec987a43ea 100644
--- a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
+++ b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
@@ -295,6 +295,7 @@ simpleExpr
| LBE_ expr (DOT_ expr)* (COMMA_ expr)* RBE_ (ON (COLUMNS | ROWS))?
| caseExpression
| privateExprOfDb
+ | matchExpression
;
functionCall
@@ -314,7 +315,21 @@ distinct
;
specialFunction
- : conversionFunction | charFunction | openJsonFunction | jsonFunction |
openRowSetFunction | windowFunction | approxFunction | openDatasourceFunction |
rowNumberFunction
+ : conversionFunction | charFunction | openJsonFunction | jsonFunction |
openRowSetFunction | windowFunction | approxFunction | openDatasourceFunction |
rowNumberFunction | graphFunction
+ ;
+
+graphFunction
+ : graphAggFunction
+ ;
+
+graphAggFunction
+ : graphAggFunctionName LP_ expr (COMMA_ expr)? RP_ WITHIN GROUP LP_ GRAPH
PATH RP_
+ ;
+
+graphAggFunctionName
+ : STRING_AGG
+ | LAST_VALUE
+ | aggregationFunctionName
;
rowNumberFunction
@@ -620,3 +635,65 @@ tableHintLimited
| UPDLOCK
| XLOCK
;
+
+matchExpression
+ : MATCH LP_ (arbitratyLengthMatch | simpleMatch) RP_
+ ;
+
+simpleMatch
+ : simpleMatchClause* (AND simpleMatch)*
+ ;
+
+simpleMatchClause
+ : lastNode
+ | nodeAlias
+ | inEdgePath
+ | outEdgePath
+ ;
+
+lastNode
+ : LAST_NODE LP_ nodeAlias RP_
+ ;
+
+arbitratyLengthMatch
+ : SHORTEST_PATH LP_ arbitraryLength RP_ (AND arbitraryLength)*
+ ;
+
+arbitraryLength
+ : arbitraryLengthClause (AND? arbitraryLengthClause)*
+ ;
+
+arbitraryLengthClause
+ : (lastNode | tableName) LP_? edgeNodeAl+ RP_? alPatternQuantifier?
+ | LP_ edgeNodeAl+ RP_ alPatternQuantifier (lastNode | tableName)
+ ;
+
+edgeNodeAl
+ : nodeAlias edgeAliasPath
+ | edgeAliasPath nodeAlias
+ ;
+
+edgeAliasPath
+ : (LT_ MINUS_ LP_ edgeAlias RP_ MINUS_) | (MINUS_ LP_ edgeAlias RP_ MINUS_
GT_)
+ ;
+
+outEdgePath
+ : MINUS_ LP_ edgeAlias RP_ MINUS_ GT_
+ ;
+
+inEdgePath
+ : LT_ MINUS_ LP_ edgeAlias RP_ MINUS_
+ ;
+
+alPatternQuantifier
+ : PLUS_
+ | LBE_ NUMBER_ COMMA_ NUMBER_ RBE_
+ ;
+
+nodeAlias
+ : tableName
+ ;
+
+edgeAlias
+ : tableName
+ ;
diff --git
a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
index d18b126449f..7d5384bf5b6 100644
---
a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
+++
b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/DMLStatement.g4
@@ -181,7 +181,7 @@ tableReference
;
tableFactor
- : tableName (AS? alias)? | subquery AS? alias columnNames? | expr (AS?
alias)? | LP_ tableReferences RP_
+ : tableName (FOR PATH)? (AS? alias)? | subquery AS? alias columnNames? |
expr (AS? alias)? | LP_ tableReferences RP_
;
joinedTable
diff --git
a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
index 6fd981aa533..42488becdfa 100644
---
a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
+++
b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
@@ -1962,3 +1962,27 @@ TRY_CONVERT
OPENQUERY
: O P E N Q U E R Y
;
+
+MATCH
+ : M A T C H
+ ;
+
+LAST_NODE
+ : L A S T UL_ N O D E
+ ;
+
+SHORTEST_PATH
+ : S H O R T E S T UL_ P A T H
+ ;
+
+STRING_AGG
+ : S T R I N G UL_ A G G
+ ;
+
+LAST_VALUE
+ : L A S T UL_ V A L U E
+ ;
+
+GRAPH
+ : G R A P H
+ ;
diff --git
a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java
b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java
index 58d0583b84f..600709517d1 100644
---
a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java
+++
b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java
@@ -136,6 +136,8 @@ import
org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.Whe
import
org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.WindowFunctionContext;
import
org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.WithClauseContext;
import
org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.WithTableHintContext;
+import
org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.GraphFunctionContext;
+import
org.apache.shardingsphere.sql.parser.autogen.SQLServerStatementParser.GraphAggFunctionContext;
import org.apache.shardingsphere.sql.parser.sql.common.enums.AggregationType;
import org.apache.shardingsphere.sql.parser.sql.common.enums.JoinType;
import org.apache.shardingsphere.sql.parser.sql.common.enums.OrderDirection;
@@ -700,9 +702,31 @@ public abstract class SQLServerStatementVisitor extends
SQLServerStatementBaseVi
if (null != ctx.approxFunction()) {
return visit(ctx.approxFunction());
}
+ if (null != ctx.graphFunction()) {
+ return visit(ctx.graphFunction());
+ }
+ return new FunctionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), ctx.getChild(0).getChild(0).getText(),
getOriginalText(ctx));
+ }
+
+ @Override
+ public ASTNode visitGraphFunction(final GraphFunctionContext ctx) {
+ if (null != ctx.graphAggFunction()) {
+ return visit(ctx.graphAggFunction());
+ }
return new FunctionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), ctx.getChild(0).getChild(0).getText(),
getOriginalText(ctx));
}
+ @Override
+ public ASTNode visitGraphAggFunction(final GraphAggFunctionContext ctx) {
+ FunctionSegment result = new
FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(),
ctx.graphAggFunctionName().getText(), getOriginalText(ctx));
+ if (null != ctx.expr()) {
+ for (ExprContext each : ctx.expr()) {
+ result.getParameters().add((ExpressionSegment) visit(each));
+ }
+ }
+ return result;
+ }
+
@Override
public final ASTNode visitApproxFunction(final ApproxFunctionContext ctx) {
FunctionSegment result = new
FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(),
ctx.funcName.getText(), getOriginalText(ctx));
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml
b/test/it/parser/src/main/resources/case/dml/select.xml
index 09a5f93060e..2ad4839e311 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -8732,4 +8732,412 @@
<simple-table name="#t" start-index="25" stop-index="26"/>
</from>
</select>
+
+ <select sql-case-id="select_with_person_simple_match_where">
+ <projections start-index="7" stop-index="32">
+ <column-projection name="name" start-index="7" stop-index="32"
alias="FriendName">
+ <owner name="Person2" start-index="7" stop-index="13"/>
+ </column-projection>
+ </projections>
+ <from start-index="39" stop-index="76">
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <simple-table name="Person" start-index="39"
stop-index="52" alias="Person1"/>
+ </left>
+ <right>
+ <simple-table name="friend" start-index="55"
stop-index="60"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person" start-index="63"
stop-index="76" alias="Person2"/>
+ </right>
+ </join-table>
+ </from>
+ <where start-index="78" stop-index="142">
+ <expr>
+ <binary-operation-expression start-index="84" stop-index="142">
+ <left>
+ <common-expression
text="MATCH(Person1-(friend)->Person2)" start-index="84" stop-index="115"/>
+ </left>
+ <operator>AND</operator>
+ <right>
+ <binary-operation-expression start-index="121"
stop-index="142">
+ <left>
+ <column name="name" start-index="121"
stop-index="132">
+ <owner name="Person1" start-index="121"
stop-index="127"/>
+ </column>
+ </left>
+ <right>
+ <literal-expression value="Alice"
start-index="136" stop-index="142"/>
+ </right>
+ <operator>=</operator>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_with_person_simple_cascade_match_where">
+ <projections start-index="7" stop-index="32">
+ <column-projection name="name" start-index="7" stop-index="32"
alias="FriendName">
+ <owner name="Person3" start-index="7" stop-index="13"/>
+ </column-projection>
+ </projections>
+ <from start-index="39" stop-index="108">
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <simple-table name="Person"
start-index="39" stop-index="52" alias="Person1"/>
+ </left>
+ <right>
+ <simple-table name="friend"
start-index="55" stop-index="60"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person"
start-index="63" stop-index="76" alias="Person2"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="friend" start-index="79"
stop-index="92" alias="friend2"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person" start-index="95"
stop-index="108" alias="Person3"/>
+ </right>
+ </join-table>
+ </from>
+ <where start-index="110" stop-index="193">
+ <expr>
+ <binary-operation-expression start-index="116"
stop-index="193">
+ <left>
+ <common-expression
text="MATCH(Person1-(friend)->Person2-(friend2)->Person3)" start-index="116"
stop-index="166"/>
+ </left>
+ <right>
+ <binary-operation-expression start-index="172"
stop-index="193">
+ <left>
+ <column name="name" start-index="172"
stop-index="183">
+ <owner name="Person1" start-index="172"
stop-index="178"/>
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="Alice"
start-index="187" stop-index="193"/>
+ </right>
+ </binary-operation-expression>
+ </right>
+ <operator>AND</operator>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_with_multi_simple_match_where">
+ <projections start-index="7" stop-index="54">
+ <column-projection name="name" start-index="7" stop-index="29"
alias="Friend1">
+ <owner name="Person1" start-index="7" stop-index="13"/>
+ </column-projection>
+ <column-projection name="name" start-index="32" stop-index="54"
alias="Friend2">
+ <owner name="Person2" start-index="32" stop-index="38"/>
+ </column-projection>
+ </projections>
+ <from start-index="61" stop-index="138">
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <simple-table name="Person"
start-index="61" stop-index="74" alias="Person1"/>
+ </left>
+ <right>
+ <simple-table name="friend"
start-index="77" stop-index="90" alias="friend1"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person"
start-index="93" stop-index="106" alias="Person2"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="friend" start-index="109"
stop-index="122" alias="friend2"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person" start-index="125"
stop-index="138" alias="Person0"/>
+ </right>
+ </join-table>
+ </from>
+ <where start-index="140" stop-index="209">
+ <expr>
+ <common-expression text="MATCH(Person1-(friend1)->Person0 AND
Person2-(friend2)->Person0)" start-index="146" stop-index="209"/>
+ </expr>
+ </where>
+ </select>
+
+ <select
sql-case-id="select_from_subquery_with_graph_agg_function_and_arbitrary_match">
+ <projections start-index="7" stop-index="25">
+ <column-projection name="PersonName" start-index="7"
stop-index="16"/>
+ <column-projection name="Friends" start-index="19"
stop-index="25"/>
+ </projections>
+ <from start-index="32" stop-index="356">
+ <subquery-table alias="Q">
+ <subquery start-index="32" stop-index="356">
+ <select>
+ <projections start-index="40" stop-index="198">
+ <column-projection name="name" start-index="40"
stop-index="65" alias="PersonName">
+ <owner name="Person1" start-index="40"
stop-index="46"/>
+ </column-projection>
+ <expression-projection
text="STRING_AGG(Person2.name, '->') WITHIN GROUP (GRAPH PATH)"
start-index="68" stop-index="134" alias="Friends">
+ <function text="STRING_AGG(Person2.name, '->')
WITHIN GROUP (GRAPH PATH)" function-name="STRING_AGG" start-index="68"
stop-index="123">
+ <parameter>
+ <column name="name" start-index="79"
stop-index="90">
+ <owner name="Person2"
start-index="79" stop-index="85"/>
+ </column>
+ </parameter>
+ <parameter>
+ <literal-expression value="->"
start-index="93" stop-index="96"/>
+ </parameter>
+ </function>
+ </expression-projection>
+ <expression-projection
text="LAST_VALUE(Person2.name) WITHIN GROUP (GRAPH PATH)" start-index="137"
stop-index="198" alias="LastNode">
+ <function text="LAST_VALUE(Person2.name)
WITHIN GROUP (GRAPH PATH)" function-name="LAST_VALUE" start-index="137"
stop-index="186">
+ <parameter>
+ <column name="name" start-index="148"
stop-index="159">
+ <owner name="Person2"
start-index="148" stop-index="154"/>
+ </column>
+ </parameter>
+ </function>
+ </expression-projection>
+ </projections>
+ <from start-index="205" stop-index="275">
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <simple-table name="Person"
start-index="205" stop-index="221" alias="Person1"/>
+ </left>
+ <right>
+ <simple-table name="friendOf"
start-index="224" stop-index="246" alias="fo"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person"
start-index="249" stop-index="275" alias="Person2"/>
+ </right>
+ </join-table>
+ </from>
+ <where start-index="277" stop-index="355">
+ <expr>
+ <binary-operation-expression start-index="283"
stop-index="355">
+ <operator>AND</operator>
+ <left>
+ <common-expression
text="MATCH(SHORTEST_PATH(Person1(-(fo)->Person2)+))" start-index="283"
stop-index="328"/>
+ </left>
+ <right>
+ <binary-operation-expression
start-index="334" stop-index="355">
+ <operator>=</operator>
+ <left>
+ <column name="name"
start-index="334" stop-index="345">
+ <owner name="Person1"
start-index="334" stop-index="340"/>
+ </column>
+ </left>
+ <right>
+ <literal-expression
value="Jacob" start-index="349" stop-index="355"/>
+ </right>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+ </subquery>
+ </subquery-table>
+ </from>
+ <where start-index="363" stop-index="388">
+ <expr>
+ <binary-operation-expression start-index="369"
stop-index="388">
+ <left>
+ <column name="LastNode" start-index="369"
stop-index="378">
+ <owner name="Q" start-index="369"
stop-index="369"/>
+ </column>
+ </left>
+ <right>
+ <literal-expression value="Alice" start-index="382"
stop-index="388"/>
+ </right>
+ <operator>=</operator>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_from_arbitrary_match_al_pattern_where">
+ <projections start-index="7" stop-index="101">
+ <column-projection name="name" start-index="7" stop-index="32"
alias="PersonName">
+ <owner name="Person1" start-index="7" stop-index="13"/>
+ </column-projection>
+ <expression-projection text="STRING_AGG(Person2.name, '->') WITHIN
GROUP (GRAPH PATH)" start-index="35" stop-index="101" alias="Friends">
+ <function text="STRING_AGG(Person2.name, '->') WITHIN GROUP
(GRAPH PATH)" function-name="STRING_AGG" start-index="35" stop-index="90">
+ <parameter>
+ <column name="name" start-index="46" stop-index="57">
+ <owner name="Person2" start-index="46"
stop-index="52"/>
+ </column>
+ </parameter>
+ <parameter>
+ <literal-expression value="->" start-index="60"
stop-index="63"/>
+ </parameter>
+ </function>
+ </expression-projection>
+ </projections>
+ <from start-index="107" stop-index="178">
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <simple-table name="Person" start-index="108"
stop-index="124" alias="Person1"/>
+ </left>
+ <right>
+ <simple-table name="friendOf" start-index="127"
stop-index="149" alias="fo"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person" start-index="152"
stop-index="178" alias="Person2"/>
+ </right>
+ </join-table>
+ </from>
+ <where start-index="180" stop-index="262">
+ <expr>
+ <binary-operation-expression start-index="186"
stop-index="262">
+ <left>
+ <common-expression
text="MATCH(SHORTEST_PATH(Person1(-(fo)->Person2){1,3}))" start-index="186"
stop-index="235"/>
+ </left>
+ <right>
+ <binary-operation-expression start-index="241"
stop-index="262">
+ <left>
+ <column name="name" start-index="241"
stop-index="252">
+ <owner name="Person1" start-index="241"
stop-index="247"/>
+ </column>
+ </left>
+ <right>
+ <literal-expression value="Jacob"
start-index="256" stop-index="262"/>
+ </right>
+ <operator>=</operator>
+ </binary-operation-expression>
+ </right>
+ <operator>AND</operator>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_with_multi_arbitrary_match">
+ <projections start-index="7" stop-index="118">
+ <column-projection name="name" start-index="7" stop-index="32"
alias="PersonName">
+ <owner name="Person1" start-index="7" stop-index="13"/>
+ </column-projection>
+ <expression-projection text="STRING_AGG(Person2.name, '->') WITHIN
GROUP (GRAPH PATH)" start-index="35" stop-index="101" alias="Friends">
+ <function text="STRING_AGG(Person2.name, '->') WITHIN GROUP
(GRAPH PATH)" function-name="STRING_AGG" start-index="35" stop-index="90">
+ <parameter>
+ <column name="name" start-index="46" stop-index="57">
+ <owner name="Person2" start-index="46"
stop-index="52"/>
+ </column>
+ </parameter>
+ <parameter>
+ <literal-expression value="->" start-index="60"
stop-index="63"/>
+ </parameter>
+ </function>
+ </expression-projection>
+ <column-projection name="name" start-index="104" stop-index="118">
+ <owner name="Restaurant" start-index="104" stop-index="113"/>
+ </column-projection>
+ </projections>
+ <from start-index="125" stop-index="214">
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <join-table join-type="COMMA">
+ <left>
+ <simple-table name="Person"
start-index="125" stop-index="141" alias="Person1"/>
+ </left>
+ <right>
+ <simple-table name="friendOf"
start-index="144" stop-index="166" alias="fo"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Person"
start-index="169" stop-index="195" alias="Person2"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="likes" start-index="198"
stop-index="202"/>
+ </right>
+ </join-table>
+ </left>
+ <right>
+ <simple-table name="Restaurant" start-index="205"
stop-index="214"/>
+ </right>
+ </join-table>
+ </from>
+ <where start-index="216" stop-index="383">
+ <expr>
+ <binary-operation-expression start-index="222"
stop-index="383">
+ <operator>AND</operator>
+ <left>
+ <binary-operation-expression start-index="222"
stop-index="342">
+ <operator>AND</operator>
+ <left>
+ <common-expression
text="MATCH(SHORTEST_PATH(Person1(-(fo)->Person2){1,3}) AND
LAST_NODE(Person2)-(likes)->Restaurant )" start-index="222" stop-index="315"/>
+ </left>
+ <right>
+ <binary-operation-expression start-index="321"
stop-index="342">
+ <operator>=</operator>
+ <left>
+ <column name="name" start-index="321"
stop-index="332">
+ <owner name="Person1"
start-index="321" stop-index="327"/>
+ </column>
+ </left>
+ <right>
+ <literal-expression value="Jacob"
start-index="336" stop-index="342"/>
+ </right>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </left>
+ <right>
+ <binary-operation-expression start-index="348"
stop-index="383">
+ <operator>=</operator>
+ <left>
+ <column name="name" start-index="348"
stop-index="362">
+ <owner name="Restaurant" start-index="348"
stop-index="357"/>
+ </column>
+ </left>
+ <right>
+ <literal-expression value="Ginger and Spice"
start-index="366" stop-index="383"/>
+ </right>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index dc6c37aa819..6147314ac3f 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -264,4 +264,10 @@
<sql-case id="select_mdx" value="SELECT {[Measures].[Internet Sales
Count], [Measures].[Internet Sales-Sales Amount]} ON COLUMNS,
{[Product].[Product Line].[Product Line].MEMBERS} ON ROWS FROM [Analysis
Services Tutorial] WHERE [Sales Territory].[Sales Territory
Country].[Australia]" db-types="SQLServer"/>
<sql-case id="select_with_brackets_case_when_alias" value="SELECT name AS
column_name,column_id,TYPE_NAME(user_type_id) AS type_name, max_length,CASE
WHEN max_length = -1 AND TYPE_NAME(user_type_id) <> 'xml' THEN 1 ELSE 0
END AS [(max)] FROM sys.columns WHERE
object_id=OBJECT_ID('<schema_name.table_name>') AND (
TYPE_NAME(user_type_id) IN ('xml','text', 'ntext','image') OR
(TYPE_NAME(user_type_id) IN ('varchar','nvarchar','varbinary') AND max_length =
-1))" db-types="SQLS [...]
<sql-case id="select_from_tmp_table_with_alias" value="SELECT Test2Col = x
FROM #t" db-types="SQLServer"/>
+ <sql-case id="select_with_person_simple_match_where" value="SELECT
Person2.name AS FriendName FROM Person Person1, friend, Person Person2 WHERE
MATCH(Person1-(friend)->Person2) AND Person1.name = 'Alice';"
db-types="SQLServer"/>
+ <sql-case id="select_with_person_simple_cascade_match_where" value="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';" db-types="SQLServer"/>
+ <sql-case id="select_with_multi_simple_match_where" value="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);"
db-types="SQLServer"/>
+ <sql-case
id="select_from_subquery_with_graph_agg_function_and_arbitrary_match"
value="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'" db-types=" [...]
+ <sql-case id="select_from_arbitrary_match_al_pattern_where" value="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'" db-types="SQLServer"/>
+ <sql-case id="select_with_multi_arbitrary_match" value="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'" db-types="SQLServer"/>
</sql-cases>