This is an automated email from the ASF dual-hosted git repository.
zclll pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 9e6926909ed [Enhancement](grammar) Support omit auto keyword for auto
range partition (#57060)
9e6926909ed is described below
commit 9e6926909ed673fa240494f310e99802d5b4aad3
Author: zclllyybb <[email protected]>
AuthorDate: Mon Oct 20 15:15:11 2025 +0800
[Enhancement](grammar) Support omit auto keyword for auto range partition
(#57060)
when use auto range partition, support omit 'auto' keyword:
```sql
CREATE TABLE not_auto_expr (
`TIME_STAMP` date NOT NULL
)
partition by range (date_trunc(`TIME_STAMP`, 'day'))()
DISTRIBUTED BY HASH(`TIME_STAMP`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
```
--- it's auto range partition
---
.../doris/nereids/parser/LogicalPlanBuilder.java | 4 ++++
.../test_auto_partition_behavior.groovy | 26 +++++++++++++++++-----
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 5c0a4ca2a53..d76be0bb3e9 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -3782,6 +3782,10 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
}
})
.collect(ImmutableList.toImmutableList());
+ // support omit 'auto' when have function expression
+ if (partitionList.stream().anyMatch(p -> p instanceof
UnboundFunction)) {
+ isAutoPartition = true;
+ }
return new PartitionTableInfo(
isAutoPartition,
ctx.RANGE() != null ? "RANGE" : "LIST",
diff --git
a/regression-test/suites/partition_p0/auto_partition/test_auto_partition_behavior.groovy
b/regression-test/suites/partition_p0/auto_partition/test_auto_partition_behavior.groovy
index 3a279693993..ef84f76fcaf 100644
---
a/regression-test/suites/partition_p0/auto_partition/test_auto_partition_behavior.groovy
+++
b/regression-test/suites/partition_p0/auto_partition/test_auto_partition_behavior.groovy
@@ -290,24 +290,38 @@ suite("test_auto_partition_behavior") {
part_result = sql " show tablets from test_change "
assertEquals(part_result.size(), 52 * replicaNum)
+ sql "drop table if exists not_auto_expr"
+ sql """
+ CREATE TABLE not_auto_expr (
+ `TIME_STAMP` date NOT NULL
+ )
+ partition by range (date_trunc(`TIME_STAMP`, 'day'))()
+ DISTRIBUTED BY HASH(`TIME_STAMP`) BUCKETS 10
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1"
+ );
+ """
+ sql """ insert into not_auto_expr values ("2020-12-12"), ("2020-12-13"),
("2020-12-14"); """
+ part_result = sql " show partitions from not_auto_expr "
+ assertEquals(part_result.size(), 3)
+ def show_result = sql " show create table not_auto_expr "
+ assertTrue(show_result[0][1].contains("AUTO PARTITION BY RANGE"))
-
- // test not auto partition have expr.
+ sql "drop table if exists not_auto_expr_list"
test {
sql """
- CREATE TABLE not_auto_expr (
+ CREATE TABLE not_auto_expr_list (
`TIME_STAMP` date NOT NULL
)
- partition by range (date_trunc(`TIME_STAMP`, 'day'))()
+ partition by list (date_trunc(`TIME_STAMP`, 'day'))()
DISTRIBUTED BY HASH(`TIME_STAMP`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
- exception "Non-auto partition table not support partition expr!"
+ exception "auto create partition only support slotRef in list
partitions"
}
-
// test insert empty
sql "create table if not exists empty_range like test_change"
sql "insert into test_change select * from empty_range"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]