You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2023/06/05 01:45:49 UTC
[shardingsphere] branch master updated: Support partition_less_than_item in openGauss sql parser (#25997)
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 5cb6ea29cf9 Support partition_less_than_item in openGauss sql parser (#25997)
5cb6ea29cf9 is described below
commit 5cb6ea29cf94dc80a616ca221f7602cf7c82fc7b
Author: cardigan1008 <87...@users.noreply.github.com>
AuthorDate: Mon Jun 5 09:45:40 2023 +0800
Support partition_less_than_item in openGauss sql parser (#25997)
* fix: add keyword SYSTEM and new test select_with_keyword_system
problem:
In MySQLStatementParser, execute() throws NoViable exception and select(
) fails to generate correct _localctx (tokens.size == 1).
* feat: select_with_keyword_system test
* fix: support create_partition_less_than
partition_less_than_item: PARTITION partition_name VALUES LESS THAN {( { partition_value | MAXVALUE } [,...] ) | MAXVALUE } [TABLESPACE [=] tablespace_name]
* delete: redundant changes
* delete: redundant changes
* fix: add new line at the end of Keyword.g4
* fix: add new line at the end of Keyword.g4
---
.../main/antlr4/imports/opengauss/DDLStatement.g4 | 3 ++-
.../src/main/antlr4/imports/opengauss/Keyword.g4 | 13 +++++++++++++
.../src/main/resources/case/ddl/create-table.xml | 22 ++++++++++++++++++++++
.../resources/sql/supported/ddl/create-table.xml | 1 +
4 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4 b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
index e4f746ed683..8aef4046a70 100644
--- a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
+++ b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
@@ -289,7 +289,7 @@ inheritClause
;
partitionSpec
- : PARTITION BY partStrategy LP_ partParams RP_
+ : PARTITION BY partStrategy LP_ partParams RP_ (LP_ partParams? RP_)*
;
partParams
@@ -299,6 +299,7 @@ partParams
partElem
: colId (COLLATE anyName)? anyName?
| LP_ aExpr RP_ (COLLATE anyName)? anyName?
+ | PARTITION anyName VALUES LESS THAN aExpr
| funcExprWindowless (COLLATE anyName)? anyName?
;
diff --git a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/Keyword.g4 b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/Keyword.g4
index 27f9f0f9d5f..74997d56eb2 100644
--- a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/Keyword.g4
+++ b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/Keyword.g4
@@ -651,3 +651,16 @@ DEC
END
: E N D
;
+
+LESS
+ : L E S S
+ ;
+
+THAN
+ : T H A N
+ ;
+
+MAXVALUE
+ : M A X V A L U E
+ ;
+
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 e3387c4be2c..3a9e2d2e587 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
@@ -1888,4 +1888,26 @@
<column name="status" />
</column-definition>
</create-table>
+
+ <create-table sql-case-id="create_table_with_partition_less_than">
+ <table name="t_sales" start-index="13" stop-index="19" />
+ <column-definition type="INTEGER" start-index="22" stop-index="46">
+ <column name="order_id" />
+ </column-definition>
+ <column-definition type="CHAR" start-index="49" stop-index="76">
+ <column name="goods_name" />
+ </column-definition>
+ <column-definition type="DATE" start-index="79" stop-index="102">
+ <column name="sales_date" />
+ </column-definition>
+ <column-definition type="INTEGER" start-index="105" stop-index="124">
+ <column name="sales_volume" />
+ </column-definition>
+ <column-definition type="CHAR" start-index="127" stop-index="146">
+ <column name="sales_store" />
+ </column-definition>
+ <constraint-definition start-index="149" stop-index="172">
+ <primary-key-column name="order_id" start-index="163" stop-index="170" />
+ </constraint-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 db5c27855bb..e87dab54f58 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
@@ -138,4 +138,5 @@
<sql-case id="create_table_with_signed_int" value="CREATE TABLE t_order (order_id INT, user_id INT, status SIGNED INT)" db-types="MySQL" />
<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-cases>