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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new bccfb04436b branch-2.1: [fix](parser) Syntax error for add partition 
with null null  #45865 (#45913)
bccfb04436b is described below

commit bccfb04436b19c632a62d01ed040fbfb6f23b930
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Dec 25 22:15:20 2024 +0800

    branch-2.1: [fix](parser) Syntax error for add partition with null null  
#45865 (#45913)
    
    Cherry-picked from #45865
    
    Co-authored-by: Uniqueyou <wangyix...@selectdb.com>
---
 fe/fe-core/src/main/cup/sql_parser.cup             | 14 ++++++
 .../test_auto_list_partition_null.groovy           | 52 ++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/fe/fe-core/src/main/cup/sql_parser.cup 
b/fe/fe-core/src/main/cup/sql_parser.cup
index ace26c55299..4250e5262e9 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -3455,6 +3455,20 @@ partition_key_item_list ::=
     {:
         RESULT = Lists.newArrayList(new PartitionValue("", true));
     :}
+    | partition_key_item_list:l COMMA KW_NULL
+    {:
+        l.add(new PartitionValue("", true));
+        RESULT = l;
+    :}
+    | KW_MAX_VALUE
+    {:
+        RESULT = Lists.newArrayList(PartitionValue.MAX_VALUE);
+    :}
+    | partition_key_item_list:l COMMA KW_MAX_VALUE
+    {:
+        l.add(PartitionValue.MAX_VALUE);
+        RESULT = l;
+    :}
     ;
 
 partition_key_list ::=
diff --git 
a/regression-test/suites/partition_p0/auto_partition/test_auto_list_partition_null.groovy
 
b/regression-test/suites/partition_p0/auto_partition/test_auto_list_partition_null.groovy
new file mode 100644
index 00000000000..16a963336e5
--- /dev/null
+++ 
b/regression-test/suites/partition_p0/auto_partition/test_auto_list_partition_null.groovy
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_auto_list_partition_null") {
+
+    sql "DROP TABLE IF EXISTS list_table_null"
+
+    sql """
+        CREATE TABLE list_table_null (
+            id int null,
+            k largeint null
+        )
+        AUTO PARTITION BY LIST (`id`, `k`)
+        (
+        )
+        DISTRIBUTED BY HASH(`k`) BUCKETS 16
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+        """
+    sql """ ALTER TABLE `list_table_null` ADD PARTITION `p1` VALUES IN ((NULL, 
"1")) ("version_info" = "1") DISTRIBUTED BY HASH(`k`) BUCKETS 16; """
+    sql """ ALTER TABLE `list_table_null` ADD PARTITION `p2` VALUES IN (("1", 
NULL)) ("version_info" = "1") DISTRIBUTED BY HASH(`k`) BUCKETS 16; """
+    sql """ ALTER TABLE `list_table_null` ADD PARTITION `p3` VALUES IN ((NULL, 
NULL)) ("version_info" = "1") DISTRIBUTED BY HASH(`k`) BUCKETS 16; """
+    sql """ ALTER TABLE `list_table_null` ADD PARTITION `p4` VALUES IN ((NULL, 
MAXVALUE)) ("version_info" = "1") DISTRIBUTED BY HASH(`k`) BUCKETS 16; """
+    sql """ ALTER TABLE `list_table_null` ADD PARTITION `p5` VALUES IN 
((MAXVALUE, NULL)) ("version_info" = "1") DISTRIBUTED BY HASH(`k`) BUCKETS 16; 
"""
+    sql """ ALTER TABLE `list_table_null` ADD PARTITION `p6` VALUES IN (("1", 
MAXVALUE)) ("version_info" = "1") DISTRIBUTED BY HASH(`k`) BUCKETS 16; """
+    sql """ ALTER TABLE `list_table_null` ADD PARTITION `p7` VALUES IN 
((MAXVALUE, "1")) ("version_info" = "1") DISTRIBUTED BY HASH(`k`) BUCKETS 16; 
"""
+
+    def res = sql "show create table list_table_null"
+
+    assertTrue(res[0][1].contains("PARTITION p3 VALUES IN ((NULL, NULL))"))
+    assertTrue(res[0][1].contains("PARTITION p1 VALUES IN ((NULL, \"1\"))"))
+    assertTrue(res[0][1].contains("PARTITION p4 VALUES IN ((NULL, MAXVALUE))"))
+    assertTrue(res[0][1].contains("PARTITION p2 VALUES IN ((\"1\", NULL))"))
+    assertTrue(res[0][1].contains("PARTITION p6 VALUES IN ((\"1\", 
MAXVALUE))"))
+    assertTrue(res[0][1].contains("PARTITION p5 VALUES IN ((MAXVALUE, NULL))"))
+    assertTrue(res[0][1].contains("PARTITION p7 VALUES IN ((MAXVALUE, 
\"1\"))"))
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to