This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new cc16f3a0d82 branch-4.0: [Enhancement](grammar) Support omit auto 
keyword for auto range partition #57060 (#57148)
cc16f3a0d82 is described below

commit cc16f3a0d824d726e581ecdaa51d98518d111e75
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Oct 22 11:42:22 2025 +0800

    branch-4.0: [Enhancement](grammar) Support omit auto keyword for auto range 
partition #57060 (#57148)
    
    Cherry-picked from #57060
    
    Co-authored-by: zclllyybb <[email protected]>
---
 .../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 a66351903c9..994c92f736a 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
@@ -3775,6 +3775,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 462fd28e988..341c38ab5aa 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
@@ -291,24 +291,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]

Reply via email to