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 9bf3c72e3d8 Support oracle format function parsing (#27248)
9bf3c72e3d8 is described below

commit 9bf3c72e3d8251bd4e38831d1300ddc67a52d0b1
Author: ZhangCheng <[email protected]>
AuthorDate: Mon Jul 17 17:54:43 2023 +0800

    Support oracle format function parsing (#27248)
    
    * Support oracle format function parsing
    
    * Support oracle format function parsing
---
 .../oracle/src/main/antlr4/imports/oracle/BaseRule.g4       |  6 +++++-
 test/it/parser/src/main/resources/case/dml/select.xml       | 13 +++++++++++++
 .../parser/src/main/resources/sql/supported/dml/select.xml  |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index d4a1ccdfc85..f50c8b84717 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -705,7 +705,11 @@ analyticFunction
     ;
 
 specialFunction
-    : castFunction  | charFunction | extractFunction
+    : castFunction  | charFunction | extractFunction | formatFunction
+    ;
+
+formatFunction
+    : (owner DOT_)* name DOT_ FORMAT LP_ expr (COMMA_ expr)* RP_
     ;
 
 castFunction
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 6e2b0b3d00f..e4fe88736e2 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -5543,4 +5543,17 @@
             </column-projection>
         </projections>
     </select>
+    
+    <select sql-case-id="select_with_format_function">
+        <from>
+            <simple-table alias="wi" name="warehouse_info" start-index="66" 
stop-index="82" literal-start-index="66" literal-stop-index="82"/>
+        </from>
+        <projections distinct-row="false" start-index="7" stop-index="59" 
literal-start-index="7" literal-stop-index="59">
+            <expression-projection text="wi.code.format(null,'PURE_IDENTITY')" 
literal-text="wi.code.format(null,'PURE_IDENTITY')" alias="PURE_IDENTITY" 
start-index="7" stop-index="59" literal-start-index="7" literal-stop-index="59">
+                <expr >
+                    <function function-name="wi" 
text="wi.code.format(null,'PURE_IDENTITY')" 
literal-text="wi.code.format(null,'PURE_IDENTITY')" start-index="7" 
stop-index="42" literal-start-index="7" literal-stop-index="42"/>
+                </expr>
+            </expression-projection>
+        </projections>
+    </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 c4cc9d9520e..7a690451f8d 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
@@ -184,4 +184,5 @@
     <sql-case id="select_with_chinese_comma" value="SELECT 1, 2,3 FROM DUAL" 
db-types="Oracle"  />
     <sql-case id="select_with_keyword_system" value="SELECT * FROM vtx_project 
WHERE system = ?" />
     <sql-case id="select_with_keyword_groups_and_rank" value="SELECT t.groups, 
t.rank FROM t_order t" db-types="MySQL" />
+    <sql-case id="select_with_format_function" value="SELECT 
wi.code.format(null,'PURE_IDENTITY') as PURE_IDENTITY FROM warehouse_info wi;" 
db-types="Oracle" />
 </sql-cases>

Reply via email to