Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] drop table keep temp partitions in recycle-bin #44097

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,6 @@ public boolean unprotectDropTable(Database db, Table table, boolean isForceDrop,
long recycleTime) {
if (table.getType() == TableType.ELASTICSEARCH) {
esRepository.deRegisterTable(table.getId());
} else if (table.isManagedTable()) {
// drop all temp partitions of this table, so that there is no temp partitions in recycle bin,
// which make things easier.
((OlapTable) table).dropAllTempPartitions();
}
if (table.getType() == TableType.MATERIALIZED_VIEW) {
Env.getCurrentEnv().getMtmvService().deregisterMTMV((MTMV) table);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql_1 --
1 1 1

-- !sql_2 --
7 1 3

-- !sql_3 --
16 1234 t

-- !sql_recover1 --
1 1 1

-- !sql_recover2 --
7 1 3

-- !sql_recover3 --
16 1234 t

-- !sql_newrecover1 --
1 1 1

-- !sql_newrecover2 --
7 1 3

-- !sql_newrecover3 --
16 1234 t

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

// 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_temp_partitions_table") {
def table = "test_temp_partitions_table"
def table2 = "test_temp_partitions_table_2"

sql """
CREATE TABLE ${table} (
id BIGINT,
val BIGINT,
str VARCHAR(114)
) DUPLICATE KEY(`id`)
PARTITION BY RANGE(`id`)
(
PARTITION `p1` VALUES LESS THAN ('5'),
PARTITION `p2` VALUES LESS THAN ('10')
)
DISTRIBUTED BY HASH(`id`) BUCKETS 3
PROPERTIES (
"replication_num"="1"
);
"""

sql """ALTER TABLE ${table} ADD TEMPORARY PARTITION tp1 VALUES [("15"), ("20"));"""

sql "INSERT INTO ${table} VALUES(1, 1,'1')"
sql "INSERT INTO ${table} VALUES(7, 1,'3')"
sql "INSERT INTO ${table} TEMPORARY PARTITION(tp1) values(16,1234, 't');"
sql "SYNC"
qt_sql_1 "SELECT * FROM ${table} PARTITION p1"
qt_sql_2 "SELECT * FROM ${table} PARTITION p2"
qt_sql_3 """select * from ${table} temporary partition(tp1);"""
sql "DROP table ${table} "
sql "recover table ${table} "

qt_sql_recover1 "SELECT * FROM ${table} PARTITION p1"
qt_sql_recover2 "SELECT * FROM ${table} PARTITION p2"
qt_sql_recover3 """select * from ${table} temporary partition(tp1);"""

sql "DROP table ${table} "
sql "recover table ${table} as ${table2}"

qt_sql_newrecover1 "SELECT * FROM ${table2} PARTITION p1"
qt_sql_newrecover2 "SELECT * FROM ${table2} PARTITION p2"
qt_sql_newrecover3 """select * from ${table2} temporary partition(tp1);"""

}
Loading