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

dataroaring 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 cc444ee8a68 [Enhancement] Insert overwrite case need to keep old 
partition data in recycle-bin (#40512)
cc444ee8a68 is described below

commit cc444ee8a683887486dec8bd810031aee3786b6d
Author: Vallish Pai <vallish...@gmail.com>
AuthorDate: Sat Sep 21 07:20:43 2024 +0530

    [Enhancement] Insert overwrite case need to keep old partition data in 
recycle-bin (#40512)
    
    ## Proposed changes
    
    Issue Number: close #xxx
    
    Insert overwrite command will trigger drop of partition and create
    partition and add the rows to table.
    In this case need to move the old data to catalog recycle bin so that
    user get chance to recover the data if needed.
---
 .../doris/insertoverwrite/InsertOverwriteUtil.java |  2 +-
 .../test_insert_overwrite_recover.out              | 14 +++++
 .../test_insert_overwrite_recover.groovy           | 64 ++++++++++++++++++++++
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/insertoverwrite/InsertOverwriteUtil.java
 
b/fe/fe-core/src/main/java/org/apache/doris/insertoverwrite/InsertOverwriteUtil.java
index 90cb8cf1fd2..c2842569ca5 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/insertoverwrite/InsertOverwriteUtil.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/insertoverwrite/InsertOverwriteUtil.java
@@ -78,7 +78,7 @@ public class InsertOverwriteUtil {
                 
properties.put(PropertyAnalyzer.PROPERTIES_USE_TEMP_PARTITION_NAME, "false");
                 ReplacePartitionClause replacePartitionClause = new 
ReplacePartitionClause(
                         new PartitionNames(false, partitionNames),
-                        new PartitionNames(true, tempPartitionNames), true, 
properties);
+                        new PartitionNames(true, tempPartitionNames), false, 
properties);
                 if (replacePartitionClause.getTempPartitionNames().isEmpty()) {
                     return;
                 }
diff --git 
a/regression-test/data/catalog_recycle_bin_p0/test_insert_overwrite_recover.out 
b/regression-test/data/catalog_recycle_bin_p0/test_insert_overwrite_recover.out
new file mode 100644
index 00000000000..eae52360da6
--- /dev/null
+++ 
b/regression-test/data/catalog_recycle_bin_p0/test_insert_overwrite_recover.out
@@ -0,0 +1,14 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select_check_1 --
+1      a       2022-01-02
+2      a       2023-01-02
+3      a       2024-01-02
+
+-- !select_check_1 --
+3      a       2024-01-02
+
+-- !select_check_1 --
+1      a       2022-01-02
+2      a       2023-01-02
+3      a       2024-01-02
+
diff --git 
a/regression-test/suites/catalog_recycle_bin_p0/test_insert_overwrite_recover.groovy
 
b/regression-test/suites/catalog_recycle_bin_p0/test_insert_overwrite_recover.groovy
new file mode 100644
index 00000000000..71faaf849ba
--- /dev/null
+++ 
b/regression-test/suites/catalog_recycle_bin_p0/test_insert_overwrite_recover.groovy
@@ -0,0 +1,64 @@
+// 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_insert_overwrite_recover") {
+    def table = "test_insert_overwrite_recover"
+
+    // create table and insert data
+    sql """ drop table if exists ${table} force"""
+    sql """
+    create table ${table} (
+        `id` int(11),
+        `name` varchar(128),
+        `da` date
+    )
+    engine=olap
+    duplicate key(id)
+    partition by range(da)(
+        PARTITION p3 VALUES LESS THAN ('2023-01-01'),
+        PARTITION p4 VALUES LESS THAN ('2024-01-01'),
+        PARTITION p5 VALUES LESS THAN ('2025-01-01')
+    )
+    distributed by hash(id) buckets 2
+    properties(
+        "replication_num"="1",
+        "light_schema_change"="true"
+    );
+    """
+
+    sql """ insert into ${table} values(1, 'a', '2022-01-02'); """
+    sql """ insert into ${table} values(2, 'a', '2023-01-02'); """
+    sql """ insert into ${table} values(3, 'a', '2024-01-02'); """
+    sql """ SYNC;"""
+
+    qt_select_check_1 """ select * from  ${table} order by id,name,da; """
+
+    sql """ insert overwrite  table ${table} values(3, 'a', '2024-01-02'); """
+
+    qt_select_check_1 """ select * from  ${table} order by id,name,da; """
+    
+    sql """ ALTER TABLE ${table} DROP PARTITION p3 force; """
+    sql """ ALTER TABLE ${table} DROP PARTITION p4 force; """
+    sql """ ALTER TABLE ${table} DROP PARTITION p5 force; """
+
+    sql """ recover partition p3  from ${table}; """
+    sql """ recover partition p4  from ${table}; """
+    sql """ recover partition p5  from ${table}; """    
+
+    qt_select_check_1 """ select * from  ${table} order by id,name,da; """
+
+}


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

Reply via email to