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 370e0b2c878 fix:Support for the PRODUCT aggregate function (#36142)
370e0b2c878 is described below

commit 370e0b2c878df43be74b0365e9fdbf5da20093ed
Author: cxy <xiaosaxiao...@qq.com>
AuthorDate: Fri Aug 1 14:21:28 2025 +0800

    fix:Support for the PRODUCT aggregate function (#36142)
---
 RELEASE-NOTES.md                                   |  1 +
 .../src/main/antlr4/imports/sqlserver/BaseRule.g4  |  4 +-
 .../antlr4/imports/sqlserver/SQLServerKeyword.g4   |  4 ++
 .../statement/core/enums/AggregationType.java      |  2 +-
 .../parser/src/main/resources/case/dml/select.xml  | 52 ++++++++++++++++++++++
 .../main/resources/sql/supported/dml/select.xml    |  1 +
 6 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index c681ee6d279..285bf72c3af 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -112,6 +112,7 @@
 1. SQL Parser: Support SQL Server the OPENDATASOURCE function in INSERT 
statements parse - [#36093](https://github.com/apache/shardingsphere/pull/36093)
 1. SQL Parser: Support SQL Server the LANGUAGE identifier parse - 
[#36110](https://github.com/apache/shardingsphere/pull/36110)
 1. SQL Parser: Support SQL Server clustered index parse - 
[#36132](https://github.com/apache/shardingsphere/pull/36132)
+1. SQL Parser: Support SQL Server the CATALOG identifier parse - 
[#36137](https://github.com/apache/shardingsphere/pull/36137)
 
 ### Bug Fixes
 
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 47c5b2b631f..5b764cfced7 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
@@ -121,7 +121,7 @@ unreservedWord
     | 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 
| SUBSTRING | RETURNS | SIZE | CONTAINS | MONTH | INPUT | YEAR
-    | TIMESTAMP | TRIM | USER | RIGHT | JSON | SID | OPENQUERY | ACTION | 
TARGET | HOUR | MINUTE | TABLE | NODES | VALUE | EXIST | CHANGETABLE | VERSION 
| CHANGES | MODEL | AI_GENERATE_EMBEDDINGS | PARAMETERS | USE | FREETEXTTABLE | 
NCHAR | LEFT | RANK | ROLLUP | PIVOT | UNPIVOT | PARSE | TRY_PARSE | 
HIERARCHYID | PATINDEX | POSITION | FORCESEEK | FORCESCAN | NOEXPAND | 
SPATIAL_WINDOW_MAX_CELLS | LANGUAGE | CATALOG
+    | TIMESTAMP | TRIM | USER | RIGHT | JSON | SID | OPENQUERY | ACTION | 
TARGET | HOUR | MINUTE | TABLE | NODES | VALUE | EXIST | CHANGETABLE | VERSION 
| CHANGES | MODEL | AI_GENERATE_EMBEDDINGS | PARAMETERS | USE | FREETEXTTABLE | 
NCHAR | LEFT | RANK | ROLLUP | PIVOT | UNPIVOT | PARSE | TRY_PARSE | 
HIERARCHYID | PATINDEX | POSITION | FORCESEEK | FORCESCAN | NOEXPAND | 
SPATIAL_WINDOW_MAX_CELLS | LANGUAGE | CATALOG | PRODUCT
     ;
 
 databaseName
@@ -315,7 +315,7 @@ aggregationFunction
     ;
 
 aggregationFunctionName
-    : MAX | MIN | SUM | COUNT | AVG | STRING_AGG
+    : MAX | MIN | SUM | COUNT | AVG | STRING_AGG | PRODUCT
     ;
 
 distinct
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 fac415d3380..7cb795d0e37 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
@@ -2114,3 +2114,7 @@ REDUCE
 REDISTRIBUTE
     : R E D I S T R I B U T E
     ;
+
+PRODUCT
+    : P R O D U C T
+    ;
diff --git 
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/enums/AggregationType.java
 
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/enums/AggregationType.java
index c5ad21974c8..fc9996e5243 100644
--- 
a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/enums/AggregationType.java
+++ 
b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/enums/AggregationType.java
@@ -24,7 +24,7 @@ import java.util.Arrays;
  */
 public enum AggregationType {
     
-    MAX, MIN, SUM, COUNT, AVG, BIT_XOR, GROUP_CONCAT;
+    MAX, MIN, SUM, COUNT, AVG, BIT_XOR, GROUP_CONCAT, PRODUCT;
     
     /**
      * Is aggregation type.
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 feef4846a39..ffbc5c9a1ca 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -11367,4 +11367,56 @@
             </expr>
         </where>
     </select>
+
+    <select sql-case-id="select_product_function">
+        <projections start-index="7" stop-index="125">
+            <column-projection name="Name" start-index="7" stop-index="12">
+                <owner name="e" start-index="7" stop-index="7"/>
+            </column-projection>
+            <aggregation-projection type="PRODUCT" expression="PRODUCT(1 + 
edh.rateOfReturn) OVER (PARTITION BY e.DepartmentID ORDER BY 
edh.EffectiveDate)" alias="CompoundedReturn" start-index="15" stop-index="105">
+                <parameter>
+                    <binary-operation-expression start-index="21" 
stop-index="42">
+                        <left>
+                            <literal-expression value="1" start-index="21" 
stop-index="21" />
+                        </left>
+                        <operator>+</operator>
+                        <right>
+                            <column name="rateOfReturn" start-index="23" 
stop-index="42">
+                                <owner name="edh" start-index="23" 
stop-index="25"/>
+                            </column>
+                        </right>
+                    </binary-operation-expression>
+                </parameter>
+            </aggregation-projection>
+        </projections>
+        <from>
+            <join-table join-type="INNER">
+                <left>
+                    <simple-table name="Employee" alias="e" start-index="132" 
stop-index="156">
+                        <owner name="HumanResources" start-index="132" 
stop-index="145"/>
+                    </simple-table>
+                </left>
+                <right>
+                    <simple-table name="EmployeePayHistory" alias="edh" 
start-index="163" stop-index="199">
+                        <owner name="HumanResources" start-index="163" 
stop-index="176"/>
+                    </simple-table>
+                </right>
+                <on-condition>
+                    <binary-operation-expression start-index="204" 
stop-index="244">
+                        <left>
+                            <column name="BusinessEntityID" start-index="204" 
stop-index="221">
+                                <owner name="e" start-index="204" 
stop-index="204"/>
+                            </column>
+                        </left>
+                        <operator>=</operator>
+                        <right>
+                            <column name="BusinessEntityID" start-index="225" 
stop-index="244">
+                                <owner name="edh" start-index="225" 
stop-index="227"/>
+                            </column>
+                        </right>
+                    </binary-operation-expression>
+                </on-condition>
+            </join-table>
+        </from>
+    </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 e6cba8fdba1..2e28d0f5efb 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
@@ -356,4 +356,5 @@
     <sql-case id="select_language_identifier" value="SELECT counter_name, 
counter_value FROM sys.dm_external_script_execution_stats WHERE language = 
'Python';" db-types="SQLServer"/>
     <sql-case id="select_with_clustered_index" value="SELECT 
e.BusinessEntityID FROM Employee e WITH (INDEX = 1) INNER JOIN Person pp ON 
e.BusinessEntityID = pp.BusinessEntityID WHERE pp.LastName = 'Johnson';" 
db-types="SQLServer"/>
     <sql-case id="select_catalog_identifier" value="SELECT catalog.name, 
catalog.catalog_id, catalog.database_id FROM sys.dm_fts_active_catalogs catalog 
WHERE catalog.database_id = DB_ID();" db-types="SQLServer"/>
+    <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-cases>

Reply via email to