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 316e802a256 support parser SQL Server SUBSTRING function (#29685)
316e802a256 is described below

commit 316e802a25628f88cbd8ce0613173b4eef58213f
Author: LotusMoon <[email protected]>
AuthorDate: Wed Jan 10 12:33:49 2024 +0800

    support parser SQL Server SUBSTRING function (#29685)
    
    * Support parsing SQL Server SUBSTRING function
    
    * fix convert function parser error
---
 .../src/main/antlr4/imports/sqlserver/BaseRule.g4  |   2 +-
 .../statement/SQLServerStatementVisitor.java       |   2 +-
 .../dml/expr/simple/LiteralExpressionSegment.java  |   2 +-
 .../parser/src/main/resources/case/dml/insert.xml  |  12 +
 .../src/main/resources/case/dml/select-join.xml    | 285 +++++++++++++++++++++
 .../parser/src/main/resources/case/dml/select.xml  |  52 +++-
 .../main/resources/sql/supported/dml/insert.xml    |   1 +
 .../resources/sql/supported/dml/select-join.xml    |   3 +
 .../main/resources/sql/supported/dml/select.xml    |   1 +
 9 files changed, 349 insertions(+), 11 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 266be49cf22..8e15fda8328 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
@@ -120,7 +120,7 @@ unreservedWord
     | DATA_RETENTION | TEMPORAL_HISTORY_RETENTION | EDITION | 
MIXED_PAGE_ALLOCATION | DISABLED | ALLOWED | HADR | MULTI_USER | 
RESTRICTED_USER | SINGLE_USER | OFFLINE | EMERGENCY | SUSPEND | 
DATE_CORRELATION_OPTIMIZATION
     | ELASTIC_POOL | SERVICE_OBJECTIVE | DATABASE_NAME | ALLOW_CONNECTIONS | 
GEO | NAMED | DATEFIRST | BACKUP_STORAGE_REDUNDANCY | 
FORCE_FAILOVER_ALLOW_DATA_LOSS | SECONDARY | FAILOVER | 
DEFAULT_FULLTEXT_LANGUAGE
     | DEFAULT_LANGUAGE | INLINE | NESTED_TRIGGERS | TRANSFORM_NOISE_WORDS | 
TWO_DIGIT_YEAR_CUTOFF | PERSISTENT_LOG_BUFFER | DIRECTORY_NAME | DATEFORMAT | 
DELAYED_DURABILITY | TRANSFER | SCHEMA | PASSWORD | AUTHORIZATION
-    | MEMBER | SEARCH | TEXT | SECOND | PRECISION | VIEWS | PROVIDER | COLUMNS
+    | MEMBER | SEARCH | TEXT | SECOND | PRECISION | VIEWS | PROVIDER | COLUMNS 
| SUBSTRING | RETURNS
     ;
 
 databaseName
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 757b1f7d7f9..7530c626f47 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
@@ -670,7 +670,7 @@ public abstract class SQLServerStatementVisitor extends 
SQLServerStatementBaseVi
         result.getParameters().add((DataTypeSegment) visit(ctx.dataType()));
         result.getParameters().add((ExpressionSegment) visit(ctx.expr()));
         if (null != ctx.NUMBER_()) {
-            result.getParameters().add(new 
LiteralExpressionSegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex(), ctx.NUMBER_().getText()));
+            result.getParameters().add(new 
LiteralExpressionSegment(ctx.NUMBER_().getSymbol().getStartIndex(), 
ctx.NUMBER_().getSymbol().getStopIndex(), ctx.NUMBER_().getText()));
         }
         return result;
     }
diff --git 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/simple/LiteralExpressionSegment.java
 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/simple/LiteralExpressionSegment.java
index d926550afa4..46197f0a633 100644
--- 
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/simple/LiteralExpressionSegment.java
+++ 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/dml/expr/simple/LiteralExpressionSegment.java
@@ -35,6 +35,6 @@ public class LiteralExpressionSegment implements 
SimpleExpressionSegment {
     
     @Override
     public String getText() {
-        return literals.toString();
+        return null != literals ? literals.toString() : null;
     }
 }
diff --git a/test/it/parser/src/main/resources/case/dml/insert.xml 
b/test/it/parser/src/main/resources/case/dml/insert.xml
index 14ce407ad7c..8310d066253 100644
--- a/test/it/parser/src/main/resources/case/dml/insert.xml
+++ b/test/it/parser/src/main/resources/case/dml/insert.xml
@@ -3061,4 +3061,16 @@
             </parameter>
         </exec>
     </insert>
+
+    <insert sql-case-id="insert_into_temp_table">
+        <table name="#NonExistentTable" start-index="12" stop-index="28"/>
+        <columns start-index="29" stop-index="29"/>
+        <values>
+            <value>
+                <assignment-value>
+                    <literal-expression value="10" start-index="38" 
stop-index="39"/>
+                </assignment-value>
+            </value>
+        </values>
+    </insert>
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/select-join.xml 
b/test/it/parser/src/main/resources/case/dml/select-join.xml
index 479dde00113..84a575c1436 100644
--- a/test/it/parser/src/main/resources/case/dml/select-join.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-join.xml
@@ -1083,4 +1083,289 @@
             </expression-item>
         </order-by>
     </select>
+
+    <select sql-case-id="select_cross_join_schema_table">
+        <projections start-index="7" stop-index="35">
+            <column-projection name="ticket" start-index="7" stop-index="14">
+                <owner name="s" start-index="7" stop-index="7"/>
+            </column-projection>
+            <column-projection name="customer" start-index="17" 
stop-index="26">
+                <owner name="s" start-index="17" stop-index="17"/>
+            </column-projection>
+            <column-projection name="store" start-index="29" stop-index="35">
+                <owner name="r" start-index="29" stop-index="29"/>
+            </column-projection>
+        </projections>
+        <from start-index="42" stop-index="83">
+            <join-table join-type="CROSS">
+                <left>
+                    <simple-table name="Sales" start-index="42" 
stop-index="55" alias="s">
+                        <owner name="dbo" start-index="42" stop-index="44"/>
+                    </simple-table>
+                </left>
+                <right>
+                    <simple-table name="Returns" start-index="68" 
stop-index="83" alias="r">
+                        <owner name="dbo" start-index="68" stop-index="70"/>
+                    </simple-table>
+                </right>
+            </join-table>
+        </from>
+        <where start-index="85" stop-index="154">
+            <expr>
+                <binary-operation-expression start-index="91" stop-index="154">
+                    <left>
+                        <binary-operation-expression start-index="91" 
stop-index="128">
+                            <left>
+                                <binary-operation-expression start-index="91" 
stop-index="109">
+                                    <left>
+                                        <column name="ticket" start-index="91" 
stop-index="98">
+                                            <owner name="s" start-index="91" 
stop-index="91"/>
+                                        </column>
+                                    </left>
+                                    <right>
+                                        <column name="ticket" 
start-index="102" stop-index="109">
+                                            <owner name="r" start-index="102" 
stop-index="102"/>
+                                        </column>
+                                    </right>
+                                    <operator>=</operator>
+                                </binary-operation-expression>
+                            </left>
+                            <right>
+                                <binary-operation-expression start-index="115" 
stop-index="128">
+                                    <left>
+                                        <column name="type" start-index="115" 
stop-index="120">
+                                            <owner name="s" start-index="115" 
stop-index="115"/>
+                                        </column>
+                                    </left>
+                                    <right>
+                                        <literal-expression value="toy" 
start-index="124" stop-index="128"/>
+                                    </right>
+                                    <operator>=</operator>
+                                </binary-operation-expression>
+                            </right>
+                            <operator>AND</operator>
+                        </binary-operation-expression>
+                    </left>
+                    <right>
+                        <binary-operation-expression start-index="134" 
stop-index="154">
+                            <left>
+                                <column name="date" start-index="134" 
stop-index="139">
+                                    <owner name="r" start-index="134" 
stop-index="134"/>
+                                </column>
+                            </left>
+                            <right>
+                                <literal-expression value="2016-05-11" 
start-index="143" stop-index="154"/>
+                            </right>
+                            <operator>=</operator>
+                        </binary-operation-expression>
+                    </right>
+                    <operator>AND</operator>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
+
+    <select sql-case-id="select_with_multi_join_01">
+        <projections start-index="7" stop-index="152">
+            <column-projection name="transaction_begin_time" start-index="7" 
stop-index="32">
+                <owner name="tat" start-index="7" stop-index="9"/>
+            </column-projection>
+            <expression-projection text="getdate()" start-index="35" 
stop-index="61" alias="current time">
+                <expr>
+                    <function function-name="getdate" text="getdate()" 
start-index="35" stop-index="43"/>
+                </expr>
+            </expression-projection>
+            <column-projection name="program_name" start-index="64" 
stop-index="78">
+                <owner name="es" start-index="64" stop-index="65"/>
+            </column-projection>
+            <column-projection name="login_time" start-index="81" 
stop-index="93">
+                <owner name="es" start-index="81" stop-index="82"/>
+            </column-projection>
+            <column-projection name="session_id" start-index="96" 
stop-index="108">
+                <owner name="es" start-index="96" stop-index="97"/>
+            </column-projection>
+            <column-projection name="open_transaction_count" start-index="111" 
stop-index="136">
+                <owner name="tst" start-index="111" stop-index="113"/>
+            </column-projection>
+            <column-projection name="event_info" start-index="139" 
stop-index="152">
+                <owner name="eib" start-index="139" stop-index="141"/>
+            </column-projection>
+        </projections>
+        <from start-index="159" stop-index="399">
+            <join-table join-type="CROSS">
+                <left>
+                    <join-table join-type="INNER">
+                        <left>
+                            <join-table join-type="INNER">
+                                <left>
+                                    <simple-table 
name="dm_tran_active_transactions" start-index="159" stop-index="193" 
alias="tat">
+                                        <owner name="sys" start-index="159" 
stop-index="161"/>
+                                    </simple-table>
+                                </left>
+                                <right>
+                                    <simple-table 
name="dm_tran_session_transactions" start-index="200" stop-index="235" 
alias="tst">
+                                        <owner name="sys" start-index="200" 
stop-index="202"/>
+                                    </simple-table>
+                                </right>
+                                <on-condition>
+                                    <binary-operation-expression 
start-index="240" stop-index="276">
+                                        <left>
+                                            <column name="transaction_id" 
start-index="240" stop-index="257">
+                                                <owner name="tat" 
start-index="240" stop-index="242"/>
+                                            </column>
+                                        </left>
+                                        <right>
+                                            <column name="transaction_id" 
start-index="259" stop-index="276">
+                                                <owner name="tst" 
start-index="259" stop-index="261"/>
+                                            </column>
+                                        </right>
+                                        <operator>=</operator>
+                                    </binary-operation-expression>
+                                </on-condition>
+                            </join-table>
+                        </left>
+                        <right>
+                            <simple-table name="dm_exec_sessions" 
start-index="283" stop-index="305" alias="es">
+                                <owner name="sys" start-index="283" 
stop-index="285"/>
+                            </simple-table>
+                        </right>
+                        <on-condition>
+                            <binary-operation-expression start-index="310" 
stop-index="337">
+                                <left>
+                                    <column name="session_id" 
start-index="310" stop-index="323">
+                                        <owner name="tst" start-index="310" 
stop-index="312"/>
+                                    </column>
+                                </left>
+                                <right>
+                                    <column name="session_id" 
start-index="325" stop-index="337">
+                                        <owner name="es" start-index="325" 
stop-index="326"/>
+                                    </column>
+                                </right>
+                                <operator>=</operator>
+                            </binary-operation-expression>
+                        </on-condition>
+                    </join-table>
+                </left>
+                <right>
+                    <function-table start-index="351" stop-index="395" 
table-alias="eib">
+                        <table-function 
text="sys.dm_exec_input_buffer(es.session_id, NULL)" 
function-name="sys.dm_exec_input_buffer">
+                            <parameter>
+                                <column name="session_id" start-index="376" 
stop-index="388">
+                                    <owner name="es" start-index="376" 
stop-index="377"/>
+                                </column>
+                            </parameter>
+                            <parameter>
+                                <literal-expression start-index="391" 
stop-index="394"/>
+                            </parameter>
+                        </table-function>
+                    </function-table>
+                </right>
+            </join-table>
+        </from>
+        <where start-index="401" stop-index="428">
+            <expr>
+                <binary-operation-expression start-index="407" 
stop-index="428">
+                    <left>
+                        <column name="is_user_process" start-index="407" 
stop-index="424">
+                            <owner name="es" start-index="407" 
stop-index="408"/>
+                        </column>
+                    </left>
+                    <right>
+                        <literal-expression value="1" start-index="428" 
stop-index="428"/>
+                    </right>
+                    <operator>=</operator>
+                </binary-operation-expression>
+            </expr>
+        </where>
+        <order-by>
+            <column-item name="transaction_begin_time" start-index="439" 
stop-index="464" order-direction="ASC">
+                <owner name="tat" start-index="439" stop-index="441"/>
+            </column-item>
+        </order-by>
+    </select>
+
+    <select sql-case-id="select_with_multi_join_02">
+        <projections start-index="7" stop-index="108">
+            <column-projection name="text" start-index="7" stop-index="10"/>
+            <expression-projection start-index="13" stop-index="108" 
alias="dbcc_freeproc_command" text="'DBCC FREEPROCCACHE (0x' + CONVERT(VARCHAR 
(512), plan_handle, 2) + ')'">
+                <expr>
+                    <binary-operation-expression start-index="13" 
stop-index="83">
+                        <left>
+                            <binary-operation-expression start-index="13" 
stop-index="77">
+                                <left>
+                                    <literal-expression value="DBCC 
FREEPROCCACHE (0x" start-index="13" stop-index="36"/>
+                                </left>
+                                <right>
+                                    <function text="CONVERT(VARCHAR (512), 
plan_handle, 2)" function-name="CONVERT" start-index="40" stop-index="77">
+                                        <parameter>
+                                            <data-type value="VARCHAR" 
start-index="48" stop-index="60" />
+                                        </parameter>
+                                        <parameter>
+                                            <column name="plan_handle" 
start-index="63" stop-index="73"/>
+                                        </parameter>
+                                        <parameter>
+                                            <literal-expression value="2" 
start-index="76" stop-index="76"/>
+                                        </parameter>
+                                    </function>
+                                </right>
+                                <operator>+</operator>
+                            </binary-operation-expression>
+                        </left>
+                        <right>
+                            <literal-expression value=")" start-index="81" 
stop-index="83"/>
+                        </right>
+                        <operator>+</operator>
+                    </binary-operation-expression>
+                </expr>
+            </expression-projection>
+        </projections>
+        <from start-index="115" stop-index="232">
+            <join-table join-type="CROSS">
+                <left>
+                    <join-table join-type="CROSS">
+                        <left>
+                            <simple-table name="dm_exec_cached_plans" 
start-index="115" stop-index="138">
+                                <owner name="sys" start-index="115" 
stop-index="117"/>
+                            </simple-table>
+                        </left>
+                        <right>
+                            <function-table start-index="152" stop-index="186">
+                                <table-function 
function-name="sys.dm_exec_query_plan" 
text="sys.dm_exec_query_plan(plan_handle)">
+                                    <parameter>
+                                        <column name="plan_handle" 
start-index="175" stop-index="185"/>
+                                    </parameter>
+                                </table-function>
+                            </function-table>
+                        </right>
+                    </join-table>
+                </left>
+                <right>
+                    <function-table start-index="200" stop-index="232">
+                        <table-function function-name="sys.dm_exec_sql_text" 
text="sys.dm_exec_sql_text(plan_handle)">
+                            <parameter>
+                                <column name="plan_handle" start-index="221" 
stop-index="231"/>
+                            </parameter>
+                        </table-function>
+                    </function-table>
+                </right>
+            </join-table>
+        </from>
+        <where start-index="234" stop-index="266">
+            <expr>
+                <binary-operation-expression start-index="240" 
stop-index="266">
+                    <left>
+                        <column name="text" start-index="240" 
stop-index="243"/>
+                    </left>
+                    <right>
+                        <list-expression start-index="250" stop-index="266">
+                            <items>
+                                <literal-expression value="%person.person%" 
start-index="250" stop-index="266"/>
+                            </items>
+                        </list-expression>
+                    </right>
+                    <operator>LIKE</operator>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
 </sql-parser-test-cases>
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 25a46d41758..f7e6678ce36 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -3885,7 +3885,7 @@
                             <function function-name="GETDATE" text="GETDATE()" 
start-index="25" stop-index="33" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="0" start-index="7" 
stop-index="37" />
+                            <literal-expression value="0" start-index="36" 
stop-index="36" />
                         </parameter>
                     </function>
                 </expr>
@@ -3929,7 +3929,7 @@
                             <literal-expression value="Name" start-index="26" 
stop-index="31" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="0" start-index="7" 
stop-index="35" />
+                            <literal-expression value="0" start-index="34" 
stop-index="34" />
                         </parameter>
                     </function>
                 </expr>
@@ -3966,7 +3966,7 @@
                             <literal-expression value="&lt;root&gt;          
&lt;child/&gt;         &lt;/root&gt;" start-index="20" stop-index="61" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="1" start-index="7" 
stop-index="65" />
+                            <literal-expression value="1" start-index="64" 
stop-index="64" />
                         </parameter>
                     </function>
                 </expr>
@@ -4000,7 +4000,7 @@
                             <function function-name="GETDATE" text="GETDATE()" 
start-index="109" stop-index="117" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="126" start-index="87" 
stop-index="123" />
+                            <literal-expression value="126" start-index="120" 
stop-index="122" />
                         </parameter>
                     </function>
                 </expr>
@@ -4037,7 +4037,7 @@
                             <literal-expression 
value="2006-04-25T15:50:59.997" start-index="129" stop-index="153" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="126" start-index="111" 
stop-index="159" />
+                            <literal-expression value="126" start-index="156" 
stop-index="158" />
                         </parameter>
                     </function>
                 </expr>
@@ -4057,7 +4057,7 @@
                             <common-expression literal-text="0x4E616d65" 
start-index="24" stop-index="33" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="0" start-index="7" 
stop-index="37" />
+                            <literal-expression value="0" start-index="36" 
stop-index="36" />
                         </parameter>
                     </function>
                 </expr>
@@ -4077,7 +4077,7 @@
                             <common-expression literal-text="0x4E616d65" 
start-index="24" stop-index="33" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="1" start-index="7" 
stop-index="37" />
+                            <literal-expression value="1" start-index="36" 
stop-index="36" />
                         </parameter>
                     </function>
                 </expr>
@@ -4097,7 +4097,7 @@
                             <literal-expression value="0x4E616D65" 
start-index="26" stop-index="37" />
                         </parameter>
                         <parameter>
-                            <literal-expression value="1" start-index="7" 
stop-index="41" />
+                            <literal-expression value="1" start-index="40" 
stop-index="40" />
                         </parameter>
                     </function>
                 </expr>
@@ -7990,4 +7990,40 @@
             <column-projection name="modify_date" start-index="185" 
stop-index="195"/>
         </projections>
     </select>
+
+    <select sql-case-id="select_with_substring_function">
+        <projections start-index="7" stop-index="36">
+            <column-projection name="ProductID" start-index="7" 
stop-index="15"/>
+            <column-projection name="Name" start-index="18" stop-index="21"/>
+            <column-projection name="ProductNumber" start-index="24" 
stop-index="36"/>
+        </projections>
+        <from start-index="43" stop-index="64">
+            <simple-table name="Product" start-index="43" stop-index="64" 
start-delimiter="[" end-delimiter="]">
+                <owner name="Production" start-index="43" stop-index="54" 
start-delimiter="[" end-delimiter="]"/>
+            </simple-table>
+        </from>
+        <where start-index="66" stop-index="110">
+            <expr>
+                <binary-operation-expression start-index="72" stop-index="110">
+                    <left>
+                        <function function-name="SUBSTRING" 
text="SUBSTRING(ProductNumber, 0, 4)"  start-index="72" stop-index="101">
+                            <parameter>
+                                <column name="ProductNumber" start-index="82" 
stop-index="94"/>
+                            </parameter>
+                            <parameter>
+                                <literal-expression value="0" start-index="97" 
stop-index="97"/>
+                            </parameter>
+                            <parameter>
+                                <literal-expression value="4" 
start-index="100" stop-index="100"/>
+                            </parameter>
+                        </function>
+                    </left>
+                    <right>
+                        <literal-expression value="HN-" start-index="106" 
stop-index="110"/>
+                    </right>
+                    <operator>=</operator>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
index de9d8a43261..f01c9ca187d 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
@@ -110,4 +110,5 @@
     <sql-case id="insert_with_data_base_name" value="INSERT INTO 
AdventureWorks2022.dbo.VariableTest(Col1) VALUES('$(tablename)')" 
db-types="SQLServer"/>
     <sql-case id="insert_with_exec" value="INSERT INTO iris_rx_data 
(&quot;Sepal.Length&quot;, &quot;Sepal.Width&quot;, &quot;Petal.Length&quot;, 
&quot;Petal.Width&quot; , &quot;Species&quot;) EXECUTE 
sp_execute_external_script @language = N'R' , @script = N'iris_data &lt;- 
iris'" db-types="SQLServer"/>
     <sql-case id="insert_with_db_schema_name" value="INSERT INTO 
ContosoWarehouse.dbo.Affiliation SELECT * FROM My_Lakehouse.dbo.Affiliation" 
db-types="SQLServer"/>
+    <sql-case id="insert_into_temp_table" value="INSERT INTO #NonExistentTable 
values (10)" db-types="SQLServer"/>
 </sql-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml
index 7a6fae3f09a..be02e203615 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml
@@ -39,4 +39,7 @@
     <sql-case id="select_inner_join_from_sys_dm_xe_objects" value="SELECT 
p.name AS [Package-Name],o.object_type,o.name AS [Object-Name],o.description AS 
[Object-Descr],p.guid AS [Package-Guid] FROM sys.dm_xe_packages AS p INNER JOIN 
sys.dm_xe_objects AS o ON p.guid = o.package_guid WHERE o.object_type = 'event' 
AND p.name LIKE '%' AND o.name LIKE '%sql%' ORDER BY p.name, o.object_type, 
o.name" db-types="SQLServer"/>
     <sql-case id="select_cross_apply_join_string_split" value="SELECT 
ProductId, Name, value FROM Product CROSS APPLY STRING_SPLIT(Tags, ',')" 
db-types="SQLServer"/>
     <sql-case id="select_cross_apply_join_string_split_with_group_by" 
value="SELECT value as tag, COUNT(*) AS [number_of_articles] FROM Product CROSS 
APPLY STRING_SPLIT(Tags, ',') GROUP BY value HAVING COUNT(*) > 2 ORDER BY 
COUNT(*) DESC" db-types="SQLServer"/>
+    <sql-case id="select_cross_join_schema_table" value="SELECT s.ticket, 
s.customer, r.store FROM dbo.Sales AS s CROSS JOIN dbo.Returns AS r WHERE 
s.ticket = r.ticket AND s.type = 'toy' AND r.date = '2016-05-11'" 
db-types="SQLServer"/>
+    <sql-case id="select_with_multi_join_01" value="SELECT 
tat.transaction_begin_time, getdate() AS 'current time', es.program_name, 
es.login_time, es.session_id, tst.open_transaction_count, eib.event_info FROM 
sys.dm_tran_active_transactions tat JOIN sys.dm_tran_session_transactions tst 
ON tat.transaction_id=tst.transaction_id JOIN sys.dm_exec_sessions es ON 
tst.session_id=es.session_id CROSS APPLY 
sys.dm_exec_input_buffer(es.session_id, NULL) eib WHERE es.is_user_process = 1 
ORDER BY t [...]
+    <sql-case id="select_with_multi_join_02" value="SELECT text, 'DBCC 
FREEPROCCACHE (0x' + CONVERT(VARCHAR (512), plan_handle, 2) + ')' AS 
dbcc_freeproc_command FROM sys.dm_exec_cached_plans CROSS APPLY 
sys.dm_exec_query_plan(plan_handle) CROSS APPLY 
sys.dm_exec_sql_text(plan_handle) WHERE text LIKE '%person.person%'" 
db-types="SQLServer"/>
 </sql-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 fd6938b456c..f466d509154 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
@@ -242,4 +242,5 @@
     <sql-case id="select_with_top_with_ties" value="SELECT TOP 10 WITH TIES 
alias1.columnName from TableName alias1" db-types="SQLServer"/>
     <sql-case id="select_with_object_id_function" value="SELECT 
OBJECT_NAME(object_id) AS referencing_object_name,COALESCE(COL_NAME(object_id, 
column_id), '(n/a)') AS referencing_column_name,* FROM sys.sql_dependencies 
WHERE referenced_major_id = OBJECT_ID('&lt;schema_name.table_name&gt;') ORDER 
BY OBJECT_NAME(object_id), COL_NAME(object_id, column_id)" 
db-types="SQLServer"/>
     <sql-case id="select_from_sys_views" value="SELECT name AS 
view_name,SCHEMA_NAME(schema_id) AS 
schema_name,OBJECTPROPERTYEX(object_id,'IsIndexed') AS 
IsIndexed,OBJECTPROPERTYEX(object_id,'IsIndexable') AS 
IsIndexable,create_date,modify_date FROM sys.views" db-types="SQLServer"/>
+    <sql-case id="select_with_substring_function" value="SELECT ProductID, 
Name, ProductNumber FROM [Production].[Product] WHERE SUBSTRING(ProductNumber, 
0, 4) =  'HN-'" db-types="SQLServer"/>
 </sql-cases>

Reply via email to