You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/11/11 02:12:34 UTC

[GitHub] [shardingsphere] jingshanglu commented on a change in pull request #13546: Add SQLServer EXPLAIN statement

jingshanglu commented on a change in pull request #13546:
URL: https://github.com/apache/shardingsphere/pull/13546#discussion_r747150295



##########
File path: shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dal/explain.xml
##########
@@ -17,8 +17,9 @@
   -->
 
 <sql-cases>
-    <sql-case id="explain_select_constant_without_table" value="EXPLAIN SELECT 1 as a" db-types="PostgreSQL,openGauss, MySQL" />
-    <sql-case id="explain_update_without_condition" value="EXPLAIN UPDATE t_order SET status = 'finished'" db-types="PostgreSQL,openGauss, MySQL" />
-    <sql-case id="explain_insert_without_parameters" value="EXPLAIN INSERT INTO t_order (order_id, user_id, status) VALUES (1, 1, 'insert')" db-types="PostgreSQL,openGauss, MySQL" />
-    <sql-case id="explain_delete_without_sharding_value" value="EXPLAIN DELETE FROM t_order WHERE status='init'" db-types="PostgreSQL,openGauss, MySQL" />
+    <sql-case id="explain_select_constant_without_table" value="EXPLAIN SELECT 1 as a" db-types="PostgreSQL, openGauss, MySQL, SQLServer" />
+    <sql-case id="explain_update_without_condition" value="EXPLAIN UPDATE t_order SET status = 'finished'" db-types="PostgreSQL, openGauss, MySQL, SQLServer" />
+    <sql-case id="explain_insert_without_parameters" value="EXPLAIN INSERT INTO t_order (order_id, user_id, status) VALUES (1, 1, 'insert')" db-types="PostgreSQL, openGauss, MySQL, SQLServer" />
+    <sql-case id="explain_delete_without_sharding_value" value="EXPLAIN DELETE FROM t_order WHERE status='init'" db-types="PostgreSQL, openGauss, MySQL, SQLServer" />
+    <sql-case id="explain_select_with_binding_tables" value="EXPLAIN SELECT G.StateProvinceName, T.SalesTerritoryGroup FROM dbo.DimGeography AS G JOIN dbo.DimSalesTerritory AS T ON G.SalesTerritoryKey = T.SalesTerritoryKey WHERE T.SalesTerritoryGroup IN ('North America', 'Pacific')" db-types="SQLServer" />

Review comment:
       @ThanoshanMV It may be better to use a uniform table name, such as `t_order`.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DALStatement.g4
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+grammar DALStatement;
+
+import SQLServerKeyword, DMLStatement;
+
+explain
+    : EXPLAIN WITH_RECOMMENDATIONS? explainableStatement
+    ;
+
+explainableStatement
+    : (select | insert | update | delete)
+    ;

Review comment:
       @ThanoshanMV It might be better to simplify to this
   ```
   explainableStatement
       : select | insert | update | delete
       ;
   ```




-- 
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