This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 264eafdfdb6 Support parsing Doris CREATE TABLE multi range partition
and per-partition properties syntax (#39201)
264eafdfdb6 is described below
commit 264eafdfdb6200f32e6d839a1520f24d012c8d90
Author: ealeonraz <[email protected]>
AuthorDate: Thu Jul 30 05:32:47 2026 -0700
Support parsing Doris CREATE TABLE multi range partition and per-partition
properties syntax (#39201)
* Support parsing Doris CREATE TABLE multi range partition and
per-partition properties syntax
* [#31495] Mark new Doris-only partition grammar rules as DORIS ADDED per
review
---
.../src/main/antlr4/imports/doris/DDLStatement.g4 | 19 +++++++-
.../src/main/resources/case/ddl/create-table.xml | 52 ++++++++++++++++++++++
.../resources/sql/supported/ddl/create-table.xml | 4 ++
3 files changed, 73 insertions(+), 2 deletions(-)
diff --git
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
index 616a46c1029..66854df3f3d 100644
---
a/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
+++
b/parser/sql/engine/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4
@@ -756,14 +756,29 @@ place
;
partitionDefinitions
- : LP_ partitionDefinition (COMMA_ partitionDefinition)* RP_
+ // DORIS CHANGED BEGIN
+ : LP_ partitionDefinitionItem (COMMA_ partitionDefinitionItem)* RP_
+ // DORIS CHANGED END
+ ;
+
+// DORIS ADDED BEGIN
+partitionDefinitionItem
+ : partitionDefinition | dorisMultiRangePartition
;
+dorisMultiRangePartition
+ : FROM LP_ expr RP_ TO LP_ expr RP_ INTERVAL expr intervalUnit?
+ ;
+// DORIS ADDED END
+
partitionDefinition
+ // DORIS CHANGED BEGIN
: PARTITION partitionName
- (VALUES (LESS THAN partitionLessThanValue | IN LP_ partitionValueList
RP_))?
+ (VALUES (LESS THAN partitionLessThanValue | IN LP_ partitionValueList RP_
| LBT_ LP_ partitionValueList RP_ COMMA_ LP_ partitionValueList RP_ RP_))?
partitionDefinitionOption*
+ (LP_ properties RP_)?
(LP_ subpartitionDefinition (COMMA_ subpartitionDefinition)* RP_)?
+ // DORIS CHANGED END
;
partitionLessThanValue
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 2464ec602ba..ca859553ec2 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
@@ -2245,6 +2245,58 @@
</column-definition>
</create-table>
+ <create-table
sql-case-id="create_table_partition_with_storage_policy_doris" db-types="Doris">
+ <table name="create_table_partion_use_created_policy" start-index="13"
stop-index="51" />
+ <column-definition type="DATE" start-index="54" stop-index="60">
+ <column name="k1" start-index="54" stop-index="55" />
+ </column-definition>
+ <column-definition type="INT" start-index="63" stop-index="68">
+ <column name="k2" start-index="63" stop-index="64" />
+ </column-definition>
+ <column-definition type="VARCHAR" agg-type="REPLACE" start-index="71"
stop-index="94">
+ <column name="V1" start-index="71" stop-index="72" />
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_multi_range_partition_date_doris"
db-types="Doris">
+ <table name="create_table_multi_partion_date" start-index="13"
stop-index="43" />
+ <column-definition type="DATE" start-index="46" stop-index="52">
+ <column name="k1" start-index="46" stop-index="47" />
+ </column-definition>
+ <column-definition type="INT" start-index="55" stop-index="60">
+ <column name="k2" start-index="55" stop-index="56" />
+ </column-definition>
+ <column-definition type="VARCHAR" start-index="63" stop-index="76">
+ <column name="V1" start-index="63" stop-index="64" />
+ </column-definition>
+ </create-table>
+
+ <create-table sql-case-id="create_table_multi_range_partition_hour_doris"
db-types="Doris">
+ <table name="create_table_multi_partion_date_hour" start-index="13"
stop-index="48" />
+ <column-definition type="DATETIME" start-index="51" stop-index="61">
+ <column name="k1" start-index="51" stop-index="52" />
+ </column-definition>
+ <column-definition type="INT" start-index="64" stop-index="69">
+ <column name="k2" start-index="64" stop-index="65" />
+ </column-definition>
+ <column-definition type="VARCHAR" start-index="72" stop-index="85">
+ <column name="V1" start-index="72" stop-index="73" />
+ </column-definition>
+ </create-table>
+
+ <create-table
sql-case-id="create_table_multi_range_partition_integer_doris" db-types="Doris">
+ <table name="create_table_multi_partion_integer" start-index="13"
stop-index="46" />
+ <column-definition type="BIGINT" start-index="49" stop-index="57">
+ <column name="k1" start-index="49" stop-index="50" />
+ </column-definition>
+ <column-definition type="INT" start-index="60" stop-index="65">
+ <column name="k2" start-index="60" stop-index="61" />
+ </column-definition>
+ <column-definition type="VARCHAR" start-index="68" stop-index="81">
+ <column name="V1" start-index="68" stop-index="69" />
+ </column-definition>
+ </create-table>
+
<create-table sql-case-id="create_table_with_select_without_query"
db-types="Oracle">
<table name="t_order_new" start-index="13" stop-index="23"/>
</create-table>
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 a14b3b08fd1..c927680b121 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
@@ -168,6 +168,10 @@
<sql-case id="create_table_with_unique_constraint_doris" value="CREATE
TABLE t_unique (id INT, UNIQUE (id))" db-types="Doris" />
<sql-case id="create_table_with_foreign_key_constraint_doris"
value="CREATE TABLE t_fk (id INT, CONSTRAINT fk_order FOREIGN KEY (id)
REFERENCES ref_table (id))" db-types="Doris" />
<sql-case id="create_table_with_inline_reference_doris" value="CREATE
TABLE t_col_fk (id INT REFERENCES ref_table(id))" db-types="Doris" />
+ <sql-case id="create_table_partition_with_storage_policy_doris"
value="CREATE TABLE create_table_partion_use_created_policy (k1 DATE, k2 INT,
V1 VARCHAR(2048) REPLACE) PARTITION BY RANGE (k1) (PARTITION p1 VALUES LESS
THAN ('2022-01-01') ('storage_policy' =
'test_create_table_partition_use_policy_1', 'replication_num'='1'), PARTITION
p2 VALUES LESS THAN ('2022-02-01') ('storage_policy' =
'test_create_table_partition_use_policy_2', 'replication_num'='1')) DISTRIBUTED
BY HASH(k2) BUCKE [...]
+ <sql-case id="create_table_multi_range_partition_date_doris" value="CREATE
TABLE create_table_multi_partion_date (k1 DATE, k2 INT, V1 VARCHAR(20))
PARTITION BY RANGE (k1) (FROM ('2000-11-14') TO ('2021-11-14') INTERVAL 1 YEAR,
FROM ('2021-11-14') TO ('2022-11-14') INTERVAL 1 MONTH, FROM ('2022-11-14') TO
('2023-01-03') INTERVAL 1 WEEK, FROM ('2023-01-03') TO ('2023-01-14') INTERVAL
1 DAY, PARTITION p_20230114 VALUES [('2023-01-14'), ('2023-01-15')))
DISTRIBUTED BY HASH(k2) BUCKETS 1 [...]
+ <sql-case id="create_table_multi_range_partition_hour_doris" value="CREATE
TABLE create_table_multi_partion_date_hour (k1 DATETIME, k2 INT, V1
VARCHAR(20)) PARTITION BY RANGE (k1) (FROM ('2023-01-03 12') TO ('2023-01-14
22') INTERVAL 1 HOUR) DISTRIBUTED BY HASH(k2) BUCKETS 1
PROPERTIES('replication_num' = '1')" db-types="Doris" />
+ <sql-case id="create_table_multi_range_partition_integer_doris"
value="CREATE TABLE create_table_multi_partion_integer (k1 BIGINT, k2 INT, V1
VARCHAR(20)) PARTITION BY RANGE (k1) (FROM (1) TO (100) INTERVAL 10)
DISTRIBUTED BY HASH(k2) BUCKETS 1 PROPERTIES('replication_num' = '1')"
db-types="Doris" />
<sql-case id="create_table_with_select_without_query" value="CREATE TABLE
t_order_new AS SELECT * FROM t_order" db-types="Oracle"/>
<sql-case id="create_table_as_select_with_pivot" value="CREATE TABLE
pivot_table AS SELECT * FROM (SELECT EXTRACT(YEAR FROM order_date) year,
order_mode, order_total FROM orders) PIVOT (SUM(order_total) FOR order_mode IN
('direct' AS Store, 'online' AS Internet));" db-types="Oracle"/>
<sql-case id="create_table_organization_index_parallel_with_select"
value="CREATE TABLE admin_iot3(i PRIMARY KEY, j, k, l) ORGANIZATION INDEX
PARALLEL AS SELECT * FROM hr.jobs" db-types="Oracle" />