This is an automated email from the ASF dual-hosted git repository. chengzhang 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 dd220f17362 fix:Support for OPTION clause in SELECT statements (#36188) dd220f17362 is described below commit dd220f173628289c285ff2cf5957ff5939e53c13 Author: cxy <xiaosaxiao...@qq.com> AuthorDate: Wed Aug 6 09:05:38 2025 +0800 fix:Support for OPTION clause in SELECT statements (#36188) --- .../main/antlr4/imports/sqlserver/DMLStatement.g4 | 2 +- .../parser/src/main/resources/case/dml/select.xml | 30 ++++++++++++++++++++++ .../main/resources/sql/supported/dml/select.xml | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) 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 92809d0c69d..a93d69f88dd 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 @@ -130,7 +130,7 @@ aggregationClause ; selectClause - : selectWithClause? SELECT duplicateSpecification? projections intoClause? onFileGroupClause? (fromClause withTempTable? withTableHint?)? whereClause? groupByClause? havingClause? orderByClause? forClause? + : selectWithClause? SELECT duplicateSpecification? projections intoClause? onFileGroupClause? (fromClause withTempTable? withTableHint?)? whereClause? groupByClause? havingClause? orderByClause? forClause? optionHint? ; duplicateSpecification 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 1bd0b997c7e..6d63746087b 100644 --- a/test/it/parser/src/main/resources/case/dml/select.xml +++ b/test/it/parser/src/main/resources/case/dml/select.xml @@ -11453,4 +11453,34 @@ </simple-table> </from> </select> + + <select sql-case-id="select_option_clause"> + <projections start-index="7" stop-index="25"> + <column-projection name="ProductID" start-index="7" stop-index="15" /> + <column-projection name="OrderQty" start-index="18" stop-index="25" /> + </projections> + <from start-index="49" stop-index="53"> + <simple-table name="SalesOrderDetail" start-index="32" stop-index="53"> + <owner name="Sales" start-index="32" stop-index="36" /> + </simple-table> + </from> + <where start-index="55" stop-index="76"> + <expr> + <binary-operation-expression start-index="61" stop-index="76"> + <left> + <column name="UnitPrice" start-index="61" stop-index="69" /> + </left> + <right> + <literal-expression value="5.00" start-index="73" stop-index="76" /> + </right> + <operator><</operator> + </binary-operation-expression> + </expr> + </where> + <group-by start-index="98" stop-index="106"> + <column-item name="ProductID" start-index="87" stop-index="95" /> + <column-item name="OrderQty" start-index="98" stop-index="105" /> + </group-by> + <option-hint start-index="107" stop-index="132" text="OPTION (HASH GROUP, LABEL = N'label1')" /> + </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 c347f51396d..dc0672f1c6b 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 @@ -359,4 +359,5 @@ <sql-case id="select_product_function" value="SELECT e.Name, PRODUCT(1 + edh.rateOfReturn) OVER (PARTITION BY e.DepartmentID ORDER BY edh.EffectiveDate) AS CompoundedReturn FROM HumanResources.Employee e JOIN HumanResources.EmployeePayHistory edh ON e.BusinessEntityID = edh.BusinessEntityID;" db-types="SQLServer"/> <sql-case id="select_for_system_time" value="SELECT DepartmentNumber, DepartmentName FROM DEPARTMENT FOR SYSTEM_TIME AS OF '2014-01-01' WHERE ManagerID = 5;" db-types="SQLServer"/> <sql-case id="select_from_tablesample" value="SELECT * FROM Sales.Customer TABLESAMPLE SYSTEM(10 PERCENT);" db-types="SQLServer"/> + <sql-case id="select_option_clause" value="SELECT ProductID, OrderQty FROM Sales.SalesOrderDetail WHERE UnitPrice < 5.00 GROUP BY ProductID, OrderQty OPTION (HASH GROUP, LABEL = N'label1');" db-types="SQLServer"/> </sql-cases>