You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/03/07 00:25:09 UTC

[shardingsphere] branch master updated: support for Repeat function (#24470)

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 19e25604761 support for Repeat function (#24470)
19e25604761 is described below

commit 19e25604761b35fd6781465d2c4b5845fbd3efa1
Author: kanha gupta <92...@users.noreply.github.com>
AuthorDate: Tue Mar 7 05:54:51 2023 +0530

    support for Repeat function (#24470)
---
 .../mysql/src/main/antlr4/imports/mysql/BaseRule.g4  |  2 +-
 .../main/resources/case/dml/select-expression.xml    | 20 ++++++++++++++++++++
 .../sql/supported/dml/select-expression.xml          |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/sql-parser/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4 b/sql-parser/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index ed7ef7c549b..3352f130e4a 100644
--- a/sql-parser/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++ b/sql-parser/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -1082,7 +1082,7 @@ completeRegularFunction
     
 regularFunctionName
     : IF | LOCALTIME | LOCALTIMESTAMP | REPLACE | INSERT | INTERVAL | MOD
-    | DATABASE | SCHEMA | LEFT | RIGHT | DATE | DAY | GEOMETRYCOLLECTION
+    | DATABASE | SCHEMA | LEFT | RIGHT | DATE | DAY | GEOMETRYCOLLECTION | REPEAT
     | LINESTRING | MULTILINESTRING | MULTIPOINT | MULTIPOLYGON | POINT | POLYGON
     | TIME | TIMESTAMP | TIMESTAMP_ADD | TIMESTAMP_DIFF | DATE | CURRENT_TIMESTAMP 
     | CURRENT_DATE | CURRENT_TIME | UTC_TIMESTAMP | identifier
diff --git a/test/it/parser/src/main/resources/case/dml/select-expression.xml b/test/it/parser/src/main/resources/case/dml/select-expression.xml
index 64d71232ecc..d846d90bea1 100644
--- a/test/it/parser/src/main/resources/case/dml/select-expression.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-expression.xml
@@ -2089,6 +2089,26 @@
         </projections>
     </select>
 
+    <select sql-case-id="select_with_repeat_function">
+        <from>
+            <simple-table name="t_order" start-index="32" stop-index="38" />
+        </from>
+      <projections start-index="7" stop-index="25">
+          <expression-projection text="REPEAT('MySQL', 3)" start-index="7" stop-index="25">
+              <expr>
+                  <function function-name="REPEAT" text="REPEAT('MySQL', 3)" start-index="7" stop-index="24">
+                      <parameter>
+                          <literal-expression value="MySQL" start-index="14" stop-index="18" />
+                      </parameter>
+                      <parameter>
+                          <literal-expression value="3" start-index="20" stop-index="20" />
+                      </parameter>
+                  </function>
+              </expr>
+          </expression-projection>
+      </projections>
+    </select>
+
     <select sql-case-id="select_with_regular_function">
         <from>
             <simple-table name="t_order" start-index="17" stop-index="23" />
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
index 17ff5f14de1..50166c9c764 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
@@ -88,6 +88,7 @@
     <sql-case id="select_with_vertical_bar" value="select 1 | 1" db-types="PostgreSQL,openGauss" />
     <sql-case id="select_with_abs_function" value="SELECT ABS(1) FROM t_order WHERE ABS(1) &gt; 1 GROUP BY ABS(1) ORDER BY ABS(1)" db-types="MySQL,Oracle" />
     <sql-case id="select_with_insert_function" value="SELECT INSERT(phone, 4, 3, '***') AS 'phone' FROM t_order" db-types="MySQL" />
+    <sql-case id="select_with_repeat_function" value="SELECT REPEAT('MySQL', 3) FROM t_order" db-types="MySQL" />
     <sql-case id="select_with_regular_function" value="SELECT A(1) FROM t_order WHERE A(1) = 1 GROUP BY A(order_id) ORDER BY A(order_id)" db-types="MySQL,Oracle,SQLServer" />
     <sql-case id="select_with_regular_function_for_sql92" value="SELECT A(1) FROM t_order WHERE A(1) = 1" db-types="MySQL,Oracle,SQLServer,H2,SQL92" />
     <sql-case id="select_with_regular_function_utc_timestamp" value="SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP())" db-types="MySQL" />