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 0e77df19b72 Support oracle negative data type parsing (#27584)
0e77df19b72 is described below
commit 0e77df19b72465d500dc5c5160b43d2b11de02b0
Author: ZhangCheng <[email protected]>
AuthorDate: Mon Jul 31 15:50:25 2023 +0800
Support oracle negative data type parsing (#27584)
---
.../oracle/src/main/antlr4/imports/oracle/BaseRule.g4 | 2 +-
.../parser/src/main/resources/case/ddl/create-table.xml | 16 ++++++++++++++++
.../main/resources/sql/supported/ddl/create-table.xml | 1 +
3 files changed, 18 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 82d36596ef4..37188a3bfeb 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
@@ -600,7 +600,7 @@ alias
;
dataTypeLength
- : LP_ (INTEGER_ (COMMA_ INTEGER_)? (CHAR | BYTE)?)? RP_
+ : LP_ (INTEGER_ (COMMA_ (MINUS_)? INTEGER_)? (CHAR | BYTE)?)? RP_
;
primaryKey
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 4112f25e6c5..9d1a21b2fa1 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
@@ -2005,4 +2005,20 @@
<primary-key-column name="order_id" start-index="163"
stop-index="170" />
</constraint-definition>
</create-table>
+
+ <create-table sql-case-id="create_table_with_negative_data_type">
+ <table name="T" start-index="13" stop-index="13"
literal-start-index="13" literal-stop-index="13" />
+ <column-definition type="NUMBER" start-index="15" stop-index="25">
+ <column name="COL1" />
+ </column-definition>
+ <column-definition type="NUMBER" start-index="28" stop-index="41">
+ <column name="COL2" />
+ </column-definition>
+ <column-definition type="NUMBER" start-index="44" stop-index="59">
+ <column name="COL3" />
+ </column-definition>
+ <column-definition type="NUMBER" start-index="62" stop-index="78">
+ <column name="COL4" />
+ </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 ecac5c78770..bfc79818444 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
@@ -147,4 +147,5 @@
<sql-case id="create_table_with_unsigned_int_cast_function" value="CREATE
TABLE t1(j json, INDEX mv_idx((CAST(j AS UNSIGNED INT ARRAY))))"
db-types="MySQL" />
<sql-case id="create_table_with_unsigned_int" value="CREATE TABLE t_order
(order_id INT, user_id INT, status UNSIGNED INT)" db-types="MySQL" />
<sql-case id="create_table_with_partition_less_than" value="CREATE TABLE
t_sales (order_id INTEGER NOT NULL, goods_name CHAR(20) NOT NULL, sales_date
DATE NOT NULL, sales_volume INTEGER, sales_store CHAR(20), PRIMARY KEY (
order_id )) PARTITION BY RANGE (sales_date) (PARTITION season1 VALUES LESS
THAN('2023-04-01 00:00:00'),PARTITION season2 VALUES LESS THAN('2023-07-01
00:00:00'),PARTITION season3 VALUES LESS THAN('2023-10-01 00:00:00'),PARTITION
season4 VALUES LESS THAN(MAXVALUE))" [...]
+ <sql-case id="create_table_with_negative_data_type" value="CREATE TABLE
T(COL1 NUMBER, COL2 NUMBER(3), COL3 NUMBER(3,2), COL4 NUMBER(6,-2))"
db-types="Oracle" />
</sql-cases>