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 9f2e624305e Support OpenGauss ts_rewrite function parse (#28313)
9f2e624305e is described below

commit 9f2e624305eb447920b6d25ba0aa26df5153c6a8
Author: Zichao <[email protected]>
AuthorDate: Thu Aug 31 13:41:37 2023 +1200

    Support OpenGauss ts_rewrite function parse (#28313)
---
 .../opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4       | 1 +
 .../opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4   | 4 +---
 .../src/main/antlr4/imports/opengauss/OpenGaussKeyword.g4         | 4 ++++
 test/it/parser/src/main/resources/case/dml/select-expression.xml  | 8 ++++++++
 .../src/main/resources/sql/supported/dml/select-expression.xml    | 1 +
 5 files changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4 
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
index 603b694b7b0..63cca97bb1d 100644
--- a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
+++ b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
@@ -1085,6 +1085,7 @@ functionExprCommonSubexpr
     | XMLROOT LP_ aExpr COMMA_ xmlRootVersion xmlRootStandalone? RP_
     | XMLSERIALIZE LP_ documentOrContent aExpr AS simpleTypeName RP_
     | PREDICT BY modelName LP_ FEATURES name (COMMA_ name)* RP_
+    | TS_REWRITE LP_ aExpr (TYPE_CAST_ TSQUERY)? (COMMA_ aExpr (TYPE_CAST_ 
TSQUERY)?)* RP_
     ;
 
 typeName
diff --git 
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
 
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
index c994e6be73f..faa94011fac 100644
--- 
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
+++ 
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DMLStatement.g4
@@ -260,9 +260,7 @@ targetList
 
 targetEl
     : colId DOT_ASTERISK_
-    | aExpr AS identifier
-    | aExpr identifier
-    | aExpr
+    | aExpr AS? identifier?
     | ASTERISK_
     ;
 
diff --git 
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/OpenGaussKeyword.g4
 
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/OpenGaussKeyword.g4
index dfe9c5cbf69..37e3d6d637d 100644
--- 
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/OpenGaussKeyword.g4
+++ 
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/OpenGaussKeyword.g4
@@ -1404,3 +1404,7 @@ PREDICT
 FEATURES
     : F E A T U R E S
     ;
+
+TS_REWRITE
+    : T S UL_ R E W R I T E
+    ;
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 5084eff3d6f..73e21de33b3 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
@@ -2969,4 +2969,12 @@
             </expression-projection>
         </projections>
     </select>
+    
+    <select sql-case-id="select_ts_rewrite_function">
+        <projections start-index="7" stop-index="62">
+            <expression-projection start-index="7" stop-index="62" 
text="ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery)">
+                <function start-index="7" stop-index="62" 
function-name="ts_rewrite" text="ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 
'c'::tsquery)" />
+            </expression-projection>
+        </projections>
+    </select>
 </sql-parser-test-cases>
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 92b4d81412e..42a0daee493 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
@@ -125,4 +125,5 @@
     <sql-case id="select_predict_by_function" value="SELECT PREDICT BY 
point_kmeans (FEATURES position) as pos FROM (select * from kmeans_2d limit 
10);" db-types="openGauss" />
     <sql-case id="select_inet_function" value="SELECT inet '192.168.1.5' = 
inet '192.168.1.5' AS RESULT;" db-types="openGauss" />
     <sql-case id="select_inet_function_with_inet_operator" value="SELECT inet 
'192.168.1.5' &lt;&lt;= inet '192.168.1.5' AS RESULT;" db-types="openGauss" />
+    <sql-case id="select_ts_rewrite_function" value="SELECT ts_rewrite('a 
&amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery);" db-types="openGauss" />
 </sql-cases>

Reply via email to