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 270f40c7647 Support parsing Oracle CREATE Table Annotations and
parallel clause (#30228)
270f40c7647 is described below
commit 270f40c764761104bfa77c5f5d9ad382942b261c
Author: LotusMoon <[email protected]>
AuthorDate: Wed Feb 21 18:55:54 2024 +0800
Support parsing Oracle CREATE Table Annotations and parallel clause (#30228)
---
.../src/main/antlr4/imports/oracle/DDLStatement.g4 | 4 +--
.../src/main/resources/case/ddl/create-table.xml | 34 ++++++++++++++++++++++
.../resources/sql/supported/ddl/create-table.xml | 4 +++
3 files changed, 40 insertions(+), 2 deletions(-)
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 722c379a586..b957e6125eb 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
@@ -242,7 +242,7 @@ oidIndexClause
;
createRelationalTableClause
- : (LP_ relationalProperties RP_)? immutableTableClauses?
blockchainTableClauses? collationClause? commitClause? physicalProperties?
tableProperties?
+ : (LP_ relationalProperties RP_)? immutableTableClauses?
blockchainTableClauses? collationClause? commitClause? parallelClause?
physicalProperties? tableProperties?
;
createParentClause
@@ -1057,7 +1057,7 @@ clusterRelatedClause
tableProperties
: columnProperties? readOnlyClause? indexingClause?
tablePartitioningClauses? attributeClusteringClause? (CACHE | NOCACHE)?
parallelClause?
- ( RESULT_CACHE (MODE (DEFAULT | FORCE)))? (ROWDEPENDENCIES |
NOROWDEPENDENCIES)? enableDisableClause* rowMovementClause?
logicalReplicationClause? flashbackArchiveClause?
+ ( RESULT_CACHE (LP_ MODE (DEFAULT | FORCE) RP_))? (ROWDEPENDENCIES |
NOROWDEPENDENCIES)? enableDisableClause* rowMovementClause?
logicalReplicationClause? flashbackArchiveClause?
( ROW ARCHIVAL)? (AS selectSubquery | FOR EXCHANGE WITH TABLE tableName)?
;
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 51bbeca5260..f6502fca603 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
@@ -2349,4 +2349,38 @@
<create-table sql-case-id="create_table_cluster_with_select3">
<table name="customers_demo" start-index="13" stop-index="26" />
</create-table>
+
+ <create-table
sql-case-id="create_table_with_ref_type_column_department_typ">
+ <table name="employees_obj" start-index="13" stop-index="25"/>
+ <column-definition type="VARCHAR2" start-index="28" stop-index="49">
+ <column name="e_name" start-index="28" stop-index="33"/>
+ </column-definition>
+ <column-definition type="NUMBER" start-index="52" stop-index="66">
+ <column name="e_number" start-index="52" stop-index="59"/>
+ </column-definition>
+ <column-definition type="department_typ" start-index="69"
stop-index="122">
+ <column name="e_dept" start-index="69" stop-index="74"/>
+ <referenced-table name="departments_obj_t" start-index="106"
stop-index="122"/>
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_with_result_cache_annotations">
+ <table name="foo" start-index="13" stop-index="15"/>
+ <column-definition type="NUMBER" start-index="18" stop-index="25">
+ <column name="a" start-index="18" stop-index="18"/>
+ </column-definition>
+ <column-definition type="VARCHAR2" start-index="28" stop-index="41">
+ <column name="b" start-index="28" stop-index="28"/>
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_with_as_sub_query">
+ <table name="employees_temp" start-index="13" stop-index="26"/>
+ </create-table>
+
+ <create-table sql-case-id="create_table_parallel_with_as_sub_query">
+ <table name="admin_emp_dept" start-index="13" stop-index="29">
+ <owner name="hr" start-index="13" stop-index="14"/>
+ </table>
+ </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 0ceecfae975..37ab8ee9706 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
@@ -318,4 +318,8 @@
<sql-case id="create_table_cluster_with_select1" value="CREATE TABLE
dept_10 CLUSTER personnel (department_id) AS SELECT * FROM employees WHERE
department_id = 10" db-types="Oracle" />
<sql-case id="create_table_cluster_with_select2" value="CREATE TABLE
dept_20 CLUSTER personnel (department_id) AS SELECT * FROM employees WHERE
department_id = 20" db-types="Oracle" />
<sql-case id="create_table_cluster_with_select3" value="CREATE TABLE
customers_demo AS SELECT * FROM customers" db-types="Oracle" />
+ <sql-case id="create_table_with_ref_type_column_department_typ"
value="CREATE TABLE employees_obj( e_name VARCHAR2(100), e_number NUMBER,
e_dept REF department_typ SCOPE IS departments_obj_t );" db-types="Oracle"/>
+ <sql-case id="create_table_with_result_cache_annotations" value="CREATE
TABLE foo (a NUMBER, b VARCHAR2(20)) RESULT_CACHE (MODE FORCE);"
db-types="Oracle"/>
+ <sql-case id="create_table_with_as_sub_query" value="CREATE TABLE
employees_temp AS SELECT * FROM EMPLOYEES;" db-types="Oracle"/>
+ <sql-case id="create_table_parallel_with_as_sub_query" value="CREATE TABLE
hr.admin_emp_dept PARALLEL COMPRESS AS SELECT * FROM hr.employees WHERE
department_id = 10;" db-types="Oracle"/>
</sql-cases>