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 f9e927ae2d8 Fix oracle create table listValuesClause syntax (#29342)
f9e927ae2d8 is described below

commit f9e927ae2d849e71e9257b88ecf4caa91948f0d6
Author: niu niu <[email protected]>
AuthorDate: Fri Dec 15 18:30:58 2023 +0800

    Fix oracle create table listValuesClause syntax (#29342)
---
 .../src/main/antlr4/imports/oracle/DDLStatement.g4 |  2 +-
 .../src/main/resources/case/ddl/create-table.xml   | 41 ++++++++++++++++++++++
 .../resources/sql/supported/ddl/create-table.xml   | 16 +++++++++
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
index 730ad975297..0b1a055eff9 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
@@ -1171,7 +1171,7 @@ listPartitions
     ;
 
 listValuesClause
-    : VALUES ( listValues | DEFAULT )
+    : VALUES LP_ (listValues | DEFAULT) RP_
     ;
 
 listValues
diff --git a/test/it/parser/src/main/resources/case/ddl/create-table.xml 
b/test/it/parser/src/main/resources/case/ddl/create-table.xml
index 5e91333654b..cda25f3bcac 100644
--- a/test/it/parser/src/main/resources/case/ddl/create-table.xml
+++ b/test/it/parser/src/main/resources/case/ddl/create-table.xml
@@ -2251,4 +2251,45 @@
             <primary-key-column name="doc_id" start-index="183" 
stop-index="188" />
         </constraint-definition>
     </create-table>
+    
+    <create-table sql-case-id="create_table_ref_type1">
+        <table name="departments_t" start-index="13" stop-index="25" />
+        <column-definition type="NUMBER" start-index="28" stop-index="38">
+            <column name="d_no" start-index="28" stop-index="31" />
+        </column-definition>
+        <column-definition type="employees_typ" start-index="41" 
stop-index="90">
+            <column name="mgr_ref" start-index="41" stop-index="47" />
+            <referenced-table name="employees_obj_t" start-index="76" 
stop-index="90" />
+        </column-definition>
+    </create-table>
+    
+    <create-table sql-case-id="create_table_ref_type2">
+        <table name="departments_t" start-index="13" stop-index="25" />
+        <column-definition type="NUMBER" start-index="28" stop-index="38">
+            <column name="d_no" start-index="28" stop-index="31" />
+        </column-definition>
+        <column-definition type="employees_typ" start-index="41" 
stop-index="114">
+            <column name="mgr_ref" start-index="41" stop-index="47" />
+            <referenced-table name="employees_obj_t" start-index="100" 
stop-index="114" />
+        </column-definition>
+    </create-table>
+    
+    <create-table sql-case-id="create_table_partition_by_range_subpartitions">
+        <table name="customers_part" start-index="13" stop-index="26" />
+        <column-definition type="NUMBER" start-index="33" stop-index="59">
+            <column name="customer_id" start-index="33" stop-index="43" />
+        </column-definition>
+        <column-definition type="VARCHAR2" start-index="66" stop-index="96">
+            <column name="cust_first_name" start-index="66" stop-index="80" />
+        </column-definition>
+        <column-definition type="VARCHAR2" start-index="103" stop-index="133">
+            <column name="cust_last_name" start-index="103" stop-index="116" />
+        </column-definition>
+        <column-definition type="VARCHAR2" start-index="140" stop-index="170">
+            <column name="nls_territory" start-index="140" stop-index="152" />
+        </column-definition>
+        <column-definition type="NUMBER" start-index="177" stop-index="206">
+            <column name="credit_limit" start-index="177" stop-index="188" />
+        </column-definition>
+    </create-table>
 </sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml 
b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
index 29baf0104c4..399c87bb8e3 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-table.xml
@@ -280,4 +280,20 @@
     TABLESPACE admin_tbs
     PCTTHRESHOLD 20
     OVERFLOW TABLESPACE admin_tbs2" db-types="Oracle" />
+    <sql-case id="create_table_ref_type1" value="CREATE TABLE departments_t 
(d_no NUMBER, mgr_ref REF employees_typ SCOPE IS employees_obj_t)" 
db-types="Oracle" />
+    <sql-case id="create_table_ref_type2" value="CREATE TABLE departments_t 
(d_no NUMBER, mgr_ref REF employees_typ CONSTRAINT mgr_in_emp REFERENCES 
employees_obj_t)" db-types="Oracle" />
+    <sql-case id="create_table_partition_by_range_subpartitions" value="CREATE 
TABLE customers_part
+    (customer_id       NUMBER(6),
+    cust_first_name    VARCHAR2(20),
+    cust_last_name     VARCHAR2(20),
+    nls_territory      VARCHAR2(30),
+    credit_limit       NUMBER(9,2)) 
+    PARTITION BY RANGE (credit_limit)
+    SUBPARTITION BY LIST (nls_territory)
+    SUBPARTITION TEMPLATE (SUBPARTITION east  VALUES ('CHINA', 'JAPAN', 
'INDIA', 'THAILAND'),
+    SUBPARTITION west VALUES ('AMERICA', 'GERMANY', 'ITALY', 'SWITZERLAND'),
+    SUBPARTITION other VALUES (DEFAULT))
+    (PARTITION p1 VALUES LESS THAN (1000),
+    PARTITION p2 VALUES LESS THAN (2500),
+    PARTITION p3 VALUES LESS THAN (MAXVALUE))" db-types="Oracle" />
 </sql-cases>

Reply via email to