diff --git a/benchmark/clickbench/hits/clear.sql b/benchmark/clickbench/hits/clear.sql index 81452994830f..e70c0347a8da 100644 --- a/benchmark/clickbench/hits/clear.sql +++ b/benchmark/clickbench/hits/clear.sql @@ -1,2 +1 @@ -drop table hits; -VACUUM DROP TABLE retain 0 hours; +drop table hits all; diff --git a/benchmark/clickbench/tpch/clear.sql b/benchmark/clickbench/tpch/clear.sql index 60b4ace1ff06..ded376e4a710 100644 --- a/benchmark/clickbench/tpch/clear.sql +++ b/benchmark/clickbench/tpch/clear.sql @@ -1,9 +1,8 @@ -drop table customer; -drop table lineitem; -drop table nation; -drop table orders; -drop table partsupp; -drop table part; -drop table region; -drop table supplier; -VACUUM DROP TABLE retain 0 hours; +drop table customer all; +drop table lineitem all; +drop table nation all; +drop table orders all; +drop table partsupp all; +drop table part all; +drop table region all; +drop table supplier all; diff --git a/benchmark/tpcds/load_data.sh b/benchmark/tpcds/load_data.sh index ca34a816b25c..b2f71f834d31 100755 --- a/benchmark/tpcds/load_data.sh +++ b/benchmark/tpcds/load_data.sh @@ -36,11 +36,9 @@ tables=( # Clear Data for t in ${tables[@]} do - echo "DROP TABLE IF EXISTS $t" | $MYSQL_CLIENT_CONNECT + echo "DROP TABLE IF EXISTS $t ALL" | $MYSQL_CLIENT_CONNECT done -echo "VACUUM DROP TABLE retain 0 hours" | $MYSQL_CLIENT_CONNECT - # Create Tables; cat "$CURDIR"/tpcds.sql | $MYSQL_CLIENT_CONNECT diff --git a/docs/doc/14-sql-commands/00-ddl/20-table/20-ddl-drop-table.md b/docs/doc/14-sql-commands/00-ddl/20-table/20-ddl-drop-table.md index 0ca931eae633..704f7253825b 100644 --- a/docs/doc/14-sql-commands/00-ddl/20-table/20-ddl-drop-table.md +++ b/docs/doc/14-sql-commands/00-ddl/20-table/20-ddl-drop-table.md @@ -18,6 +18,9 @@ DROP TABLE [IF EXISTS] [db.]name :::caution `DROP TABLE` only remove the table schema from meta service, we do not remove the underlying data from the storage. +If you want to delete the data and table all, please use: + +`DROP TABLE ALL;` ::: diff --git a/docs/doc/14-sql-commands/00-ddl/20-table/40-ddl-truncate-table.md b/docs/doc/14-sql-commands/00-ddl/20-table/40-ddl-truncate-table.md index 9f8cabac2fc2..68592fc28c60 100644 --- a/docs/doc/14-sql-commands/00-ddl/20-table/40-ddl-truncate-table.md +++ b/docs/doc/14-sql-commands/00-ddl/20-table/40-ddl-truncate-table.md @@ -2,14 +2,14 @@ title: TRUNCATE TABLE --- -Removes all data from a table while preserving the table's schema. It deletes all rows in the table, making it an empty table with the same columns and constraints. Please note that, it does not release the disk space allocated to the table. +Removes all data from a table while preserving the table's schema. It deletes all rows in the table, making it an empty table with the same columns and constraints. Please note that, it does not release the disk space allocated to the table. To release the disk space, include the PURGE option, which is used to release the disk space allocated to the table when the truncate operation is performed. See also: [DROP TABLE](20-ddl-drop-table.md) ## Syntax ```sql -TRUNCATE TABLE [db.]table_name +TRUNCATE TABLE [db.]table_name [PURGE] ``` ## Examples @@ -50,4 +50,10 @@ FROM test_truncate 0 row in 0.017 sec. Processed 0 rows, 0B (0 rows/s, 0B/s) + +root@localhost> TRUNCATE TABLE test_truncate PURGE; + +TRUNCATE TABLE test_truncate PURGE + +0 row in 0.118 sec. Processed 0 rows, 0B (0 rows/s, 0B/s) ``` \ No newline at end of file diff --git a/scripts/benchmark/query/load/hits.sh b/scripts/benchmark/query/load/hits.sh index f0c6d2a99576..9754e6020532 100755 --- a/scripts/benchmark/query/load/hits.sh +++ b/scripts/benchmark/query/load/hits.sh @@ -7,11 +7,7 @@ select version(); SQL cat <, pub database: Option, pub table: Identifier, + pub all: bool, } impl Display for DropTableStmt { @@ -271,6 +272,9 @@ impl Display for DropTableStmt { .chain(&self.database) .chain(Some(&self.table)), )?; + if self.all { + write!(f, " ALL")?; + } Ok(()) } @@ -464,6 +468,7 @@ pub struct TruncateTableStmt { pub catalog: Option, pub database: Option, pub table: Identifier, + pub purge: bool, } impl Display for TruncateTableStmt { @@ -476,6 +481,9 @@ impl Display for TruncateTableStmt { .chain(&self.database) .chain(Some(&self.table)), )?; + if self.purge { + write!(f, " PURGE")?; + } Ok(()) } diff --git a/src/query/ast/src/parser/statement.rs b/src/query/ast/src/parser/statement.rs index 2e2f74ad0651..2b74cf933a2c 100644 --- a/src/query/ast/src/parser/statement.rs +++ b/src/query/ast/src/parser/statement.rs @@ -575,14 +575,15 @@ pub fn statement(i: Input) -> IResult { ); let drop_table = map( rule! { - DROP ~ TABLE ~ ( IF ~ ^EXISTS )? ~ #dot_separated_idents_1_to_3 + DROP ~ TABLE ~ ( IF ~ ^EXISTS )? ~ #dot_separated_idents_1_to_3 ~ ALL? }, - |(_, _, opt_if_exists, (catalog, database, table))| { + |(_, _, opt_if_exists, (catalog, database, table), opt_all)| { Statement::DropTable(DropTableStmt { if_exists: opt_if_exists.is_some(), catalog, database, table, + all: opt_all.is_some(), }) }, ); @@ -635,13 +636,14 @@ pub fn statement(i: Input) -> IResult { ); let truncate_table = map( rule! { - TRUNCATE ~ TABLE ~ #dot_separated_idents_1_to_3 + TRUNCATE ~ TABLE ~ #dot_separated_idents_1_to_3 ~ PURGE? }, - |(_, _, (catalog, database, table))| { + |(_, _, (catalog, database, table), opt_purge)| { Statement::TruncateTable(TruncateTableStmt { catalog, database, table, + purge: opt_purge.is_some(), }) }, ); @@ -1457,7 +1459,7 @@ pub fn statement(i: Input) -> IResult { | #undrop_table : "`UNDROP TABLE [.]`" | #alter_table : "`ALTER TABLE [.]
`" | #rename_table : "`RENAME TABLE [.]
TO `" - | #truncate_table : "`TRUNCATE TABLE [.]
`" + | #truncate_table : "`TRUNCATE TABLE [.]
[PURGE]`" | #optimize_table : "`OPTIMIZE TABLE [.]
(ALL | PURGE | COMPACT [SEGMENT])`" | #vacuum_table : "`VACUUM TABLE [.]
[RETAIN number HOURS] [DRY RUN]`" | #vacuum_drop_table : "`VACUUM DROP TABLE [FROM [.]] [RETAIN number HOURS] [DRY RUN]`" diff --git a/src/query/ast/tests/it/testdata/statement-error.txt b/src/query/ast/tests/it/testdata/statement-error.txt index 1bc5b7022818..41fb06a12f08 100644 --- a/src/query/ast/tests/it/testdata/statement-error.txt +++ b/src/query/ast/tests/it/testdata/statement-error.txt @@ -109,7 +109,7 @@ error: --> SQL:1:21 | 1 | truncate table a.b.c.d - | ^ expected `FORMAT` or `;` + | ^ expected `PURGE`, `FORMAT`, or `;` ---------- Input ---------- @@ -121,7 +121,7 @@ error: 1 | truncate a | -------- ^ expected `TABLE` | | - | while parsing `TRUNCATE TABLE [.]
` + | while parsing `TRUNCATE TABLE [.]
[PURGE]` ---------- Input ---------- diff --git a/src/query/ast/tests/it/testdata/statement.txt b/src/query/ast/tests/it/testdata/statement.txt index f456112a13c2..6529e62b49c1 100644 --- a/src/query/ast/tests/it/testdata/statement.txt +++ b/src/query/ast/tests/it/testdata/statement.txt @@ -1462,6 +1462,7 @@ TruncateTable( 15..16, ), }, + purge: false, }, ) @@ -1492,6 +1493,7 @@ TruncateTable( 19..20, ), }, + purge: false, }, ) @@ -1513,6 +1515,7 @@ DropTable( 11..12, ), }, + all: false, }, ) @@ -1544,6 +1547,7 @@ DropTable( 23..26, ), }, + all: false, }, ) @@ -2355,6 +2359,7 @@ TruncateTable( 15..19, ), }, + purge: false, }, ) @@ -2383,6 +2388,7 @@ TruncateTable( 23..27, ), }, + purge: false, }, ) @@ -2404,6 +2410,7 @@ DropTable( 11..17, ), }, + all: false, }, ) @@ -2425,6 +2432,7 @@ DropTable( 21..27, ), }, + all: false, }, ) diff --git a/src/query/catalog/src/table.rs b/src/query/catalog/src/table.rs index 5681e078decd..c35e4de7ec8c 100644 --- a/src/query/catalog/src/table.rs +++ b/src/query/catalog/src/table.rs @@ -214,8 +214,8 @@ pub trait Table: Sync + Send { } #[async_backtrace::framed] - async fn truncate(&self, ctx: Arc) -> Result<()> { - let _ = ctx; + async fn truncate(&self, ctx: Arc, purge: bool) -> Result<()> { + let (_, _) = (ctx, purge); Ok(()) } diff --git a/src/query/ee/tests/it/aggregating_index/index_scan.rs b/src/query/ee/tests/it/aggregating_index/index_scan.rs index 6ddfa982dbab..43e1cca22a3b 100644 --- a/src/query/ee/tests/it/aggregating_index/index_scan.rs +++ b/src/query/ee/tests/it/aggregating_index/index_scan.rs @@ -1110,8 +1110,8 @@ async fn test_fuzz_impl(format: &str, spill: bool) -> Result<()> { } // Clear data - execute_sql(fixture.ctx(), "DROP TABLE rt").await?; - execute_sql(fixture.ctx(), "DROP TABLE t").await?; + execute_sql(fixture.ctx(), "DROP TABLE rt ALL").await?; + execute_sql(fixture.ctx(), "DROP TABLE t ALL").await?; } } Ok(()) diff --git a/src/query/service/src/api/rpc/packets/packet_truncate_table.rs b/src/query/service/src/api/rpc/packets/packet_truncate_table.rs index 75670a86214c..cc6ddae0c08b 100644 --- a/src/query/service/src/api/rpc/packets/packet_truncate_table.rs +++ b/src/query/service/src/api/rpc/packets/packet_truncate_table.rs @@ -25,6 +25,7 @@ use crate::api::FlightAction; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] pub struct TruncateTablePacket { + pub purge: bool, pub table_name: String, pub catalog_name: String, pub database_name: String, @@ -37,8 +38,10 @@ impl TruncateTablePacket { table_name: String, catalog_name: String, database_name: String, + purge: bool, ) -> TruncateTablePacket { TruncateTablePacket { + purge, table_name, catalog_name, database_name, diff --git a/src/query/service/src/interpreters/interpreter_table_drop.rs b/src/query/service/src/interpreters/interpreter_table_drop.rs index 362695d296e3..ba9a59b6f7ae 100644 --- a/src/query/service/src/interpreters/interpreter_table_drop.rs +++ b/src/query/service/src/interpreters/interpreter_table_drop.rs @@ -14,6 +14,7 @@ use std::sync::Arc; +use common_catalog::table::TableExt; use common_exception::ErrorCode; use common_exception::Result; use common_meta_app::schema::DropTableByIdReq; @@ -77,6 +78,15 @@ impl Interpreter for DropTableInterpreter { }) .await?; + // if `plan.all`, truncate, then purge the historical data + if self.plan.all { + let purge = true; + // the above `catalog.drop_table` operation changed the table meta version, + // thus if we do not refresh the table instance, `truncate` will fail + let latest = tbl.as_ref().refresh(self.ctx.as_ref()).await?; + latest.truncate(self.ctx.clone(), purge).await? + } + if let Some((spec_vec, share_table_info)) = resp.spec_vec { save_share_spec( &self.ctx.get_tenant(), diff --git a/src/query/service/src/interpreters/interpreter_table_truncate.rs b/src/query/service/src/interpreters/interpreter_table_truncate.rs index 2b2eb0836644..a75f1a976b92 100644 --- a/src/query/service/src/interpreters/interpreter_table_truncate.rs +++ b/src/query/service/src/interpreters/interpreter_table_truncate.rs @@ -27,6 +27,7 @@ use crate::sessions::TableContext; pub struct TruncateTableInterpreter { ctx: Arc, + purge: bool, table_name: String, catalog_name: String, database_name: String, @@ -38,6 +39,7 @@ impl TruncateTableInterpreter { pub fn try_create(ctx: Arc, plan: TruncateTablePlan) -> Result { Ok(TruncateTableInterpreter { ctx, + purge: plan.purge, table_name: plan.table, catalog_name: plan.catalog, database_name: plan.database, @@ -48,6 +50,7 @@ impl TruncateTableInterpreter { pub fn from_flight(ctx: Arc, packet: TruncateTablePacket) -> Result { Ok(TruncateTableInterpreter { ctx, + purge: packet.purge, table_name: packet.table_name, catalog_name: packet.catalog_name, database_name: packet.database_name, @@ -81,13 +84,14 @@ impl Interpreter for TruncateTableInterpreter { self.table_name.clone(), self.catalog_name.clone(), self.database_name.clone(), + self.purge, ); truncate_packet.commit(conf.as_ref(), timeout).await?; } } } - table.truncate(self.ctx.clone()).await?; + table.truncate(self.ctx.clone(), self.purge).await?; Ok(PipelineBuildResult::create()) } } diff --git a/src/query/service/tests/it/storages/fuse/operations/analyze.rs b/src/query/service/tests/it/storages/fuse/operations/analyze.rs index 46eb0cc9c44d..bc9498c5ca5a 100644 --- a/src/query/service/tests/it/storages/fuse/operations/analyze.rs +++ b/src/query/service/tests/it/storages/fuse/operations/analyze.rs @@ -77,7 +77,7 @@ async fn test_fuse_snapshot_analyze_and_truncate() -> Result<()> { .get_table(ctx.get_tenant().as_str(), &db, &tbl) .await?; let fuse_table = FuseTable::try_from_table(table.as_ref())?; - fuse_table.truncate(ctx).await?; + fuse_table.truncate(ctx, false).await?; } // optimize after truncate table, ts file location will become None diff --git a/src/query/service/tests/it/storages/fuse/operations/gc.rs b/src/query/service/tests/it/storages/fuse/operations/gc.rs index 447ddcc394c0..512436f2d875 100644 --- a/src/query/service/tests/it/storages/fuse/operations/gc.rs +++ b/src/query/service/tests/it/storages/fuse/operations/gc.rs @@ -114,9 +114,9 @@ async fn test_fuse_purge_normal_orphan_snapshot() -> Result<()> { "do_gc: there should be 1 snapshot, 0 segment/block", expected_num_of_snapshot, 0, // 0 snapshot statistic - 1, // 1 segments - 1, // 1 blocks - 1, // 1 index + 1, // 0 segments + 1, // 0 blocks + 1, // 0 index Some(()), None, ) diff --git a/src/query/service/tests/it/storages/fuse/operations/mod.rs b/src/query/service/tests/it/storages/fuse/operations/mod.rs index 7b22f3c11852..9d9d8e8a6175 100644 --- a/src/query/service/tests/it/storages/fuse/operations/mod.rs +++ b/src/query/service/tests/it/storages/fuse/operations/mod.rs @@ -23,6 +23,7 @@ mod mutation; mod navigate; mod optimize; mod purge_drop; +mod purge_truncate; mod read_plan; mod replace_into; mod table_analyze; diff --git a/src/query/service/tests/it/storages/fuse/operations/purge_drop.rs b/src/query/service/tests/it/storages/fuse/operations/purge_drop.rs index b78191acce2f..4c9e7762c5ca 100644 --- a/src/query/service/tests/it/storages/fuse/operations/purge_drop.rs +++ b/src/query/service/tests/it/storages/fuse/operations/purge_drop.rs @@ -15,6 +15,7 @@ use common_base::base::tokio; use common_exception::Result; use databend_query::test_kits::table_test_fixture::append_sample_data; +use databend_query::test_kits::table_test_fixture::check_data_dir; use databend_query::test_kits::table_test_fixture::execute_command; use databend_query::test_kits::table_test_fixture::TestFixture; @@ -33,3 +34,32 @@ async fn test_fuse_snapshot_truncate_in_drop_stmt() -> Result<()> { execute_command(ctx.clone(), qry.as_str()).await?; Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_fuse_snapshot_truncate_in_drop_all_stmt() -> Result<()> { + let fixture = TestFixture::new().await; + let db = fixture.default_db_name(); + let tbl = fixture.default_table_name(); + let ctx = fixture.ctx(); + fixture.create_default_table().await?; + + // ingests some test data + append_sample_data(1, &fixture).await?; + // let's Drop + let qry = format!("drop table {}.{} all", db, tbl); + execute_command(ctx.clone(), qry.as_str()).await?; + + check_data_dir( + &fixture, + "drop table: there should be 1 snapshot, 0 segment/block", + 1, // 1 snapshot + 0, // 0 snapshot statistic + 0, // 0 segments + 0, // 0 blocks + 0, // 0 index + None, + None, + ) + .await?; + Ok(()) +} diff --git a/src/query/service/tests/it/storages/fuse/operations/purge_truncate.rs b/src/query/service/tests/it/storages/fuse/operations/purge_truncate.rs new file mode 100644 index 000000000000..86c6baf7e692 --- /dev/null +++ b/src/query/service/tests/it/storages/fuse/operations/purge_truncate.rs @@ -0,0 +1,75 @@ +// Copyright 2021 Datafuse Labs. +// +// Licensed 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. +use common_base::base::tokio; +use common_exception::Result; +use databend_query::test_kits::table_test_fixture::append_sample_data; +use databend_query::test_kits::table_test_fixture::check_data_dir; +use databend_query::test_kits::table_test_fixture::execute_command; +use databend_query::test_kits::table_test_fixture::history_should_have_item; +use databend_query::test_kits::table_test_fixture::TestFixture; + +#[tokio::test(flavor = "multi_thread")] +async fn test_fuse_truncate_purge_stmt() -> Result<()> { + let fixture = TestFixture::new().await; + let db = fixture.default_db_name(); + let tbl = fixture.default_table_name(); + let ctx = fixture.ctx(); + fixture.create_default_table().await?; + + // ingests some 2 blocks + append_sample_data(1, &fixture).await?; + append_sample_data(1, &fixture).await?; + + let expected_index_count = 2; + // there should be some data there: 2 snapshot, 2 segment, 2 block + check_data_dir( + &fixture, + "truncate_purge", + 2, + 0, + 2, + 2, + expected_index_count, + Some(()), + None, + ) + .await?; + + // let's truncate + let qry = format!("truncate table {}.{} purge", db, tbl); + execute_command(ctx.clone(), qry.as_str()).await?; + + // one history item left there + history_should_have_item( + &fixture, + "after_truncate_there_should_be_one_history_item_left", + 1, + ) + .await?; + + // there should be only a snapshot file left there, no segments or blocks + check_data_dir( + &fixture, + "truncate_after_purge_check_file_items", + 1, + 0, + 0, + 0, + 0, + Some(()), + None, + ) + .await?; + Ok(()) +} diff --git a/src/query/service/tests/it/storages/fuse/operations/truncate.rs b/src/query/service/tests/it/storages/fuse/operations/truncate.rs index 967ae9dd6a5f..eae28a6e3538 100644 --- a/src/query/service/tests/it/storages/fuse/operations/truncate.rs +++ b/src/query/service/tests/it/storages/fuse/operations/truncate.rs @@ -34,7 +34,7 @@ async fn test_fuse_table_truncate() -> common_exception::Result<()> { // 1. truncate empty table let prev_version = table.get_table_info().ident.seq; - let r = table.truncate(ctx.clone()).await; + let r = table.truncate(ctx.clone(), false).await; let table = fixture.latest_default_table().await?; // no side effects assert_eq!(prev_version, table.get_table_info().ident.seq); @@ -66,7 +66,8 @@ async fn test_fuse_table_truncate() -> common_exception::Result<()> { assert_eq!(stats.read_rows, (num_blocks * rows_per_block)); // truncate - let r = table.truncate(ctx.clone()).await; + let purge = false; + let r = table.truncate(ctx.clone(), purge).await; assert!(r.is_ok()); // get the latest tbl @@ -146,7 +147,8 @@ async fn test_fuse_table_truncate_appending_concurrently() -> common_exception:: let s2_table_to_appended = fixture.latest_default_table().await?; // 4. perform `truncate purge` operation on s1 - let r = s1_table_to_be_truncated.truncate(ctx.clone()).await; + let purge = true; + let r = s1_table_to_be_truncated.truncate(ctx.clone(), purge).await; // version mismatched, and `truncate purge` should result in error (but nothing should have been removed) assert!(r.is_err()); diff --git a/src/query/service/tests/it/storages/null.rs b/src/query/service/tests/it/storages/null.rs index fe5494af29f4..2876aceec182 100644 --- a/src/query/service/tests/it/storages/null.rs +++ b/src/query/service/tests/it/storages/null.rs @@ -62,7 +62,8 @@ async fn test_null_table() -> Result<()> { // truncate. { - table.truncate(ctx).await?; + let purge = false; + table.truncate(ctx, purge).await?; } Ok(()) diff --git a/src/query/sql/src/planner/binder/ddl/table.rs b/src/query/sql/src/planner/binder/ddl/table.rs index 655cf3fb4785..df82edbccc8f 100644 --- a/src/query/sql/src/planner/binder/ddl/table.rs +++ b/src/query/sql/src/planner/binder/ddl/table.rs @@ -666,6 +666,7 @@ impl Binder { catalog, database, table, + all, } = stmt; let tenant = self.ctx.get_tenant(); @@ -678,6 +679,7 @@ impl Binder { catalog, database, table, + all: *all, }))) } @@ -969,6 +971,7 @@ impl Binder { catalog, database, table, + purge, } = stmt; let (catalog, database, table) = @@ -978,6 +981,7 @@ impl Binder { catalog, database, table, + purge: *purge, }))) } diff --git a/src/query/sql/src/planner/plans/ddl/table.rs b/src/query/sql/src/planner/plans/ddl/table.rs index 899eae287f8a..c447a07bb680 100644 --- a/src/query/sql/src/planner/plans/ddl/table.rs +++ b/src/query/sql/src/planner/plans/ddl/table.rs @@ -84,6 +84,7 @@ pub struct DropTablePlan { pub database: String, /// The table name pub table: String, + pub all: bool, } impl DropTablePlan { @@ -323,6 +324,7 @@ pub struct TruncateTablePlan { pub database: String, /// The table name pub table: String, + pub purge: bool, } impl TruncateTablePlan { diff --git a/src/query/storages/fuse/src/fuse_table.rs b/src/query/storages/fuse/src/fuse_table.rs index 71039e682160..a0ccda0c0f87 100644 --- a/src/query/storages/fuse/src/fuse_table.rs +++ b/src/query/storages/fuse/src/fuse_table.rs @@ -553,8 +553,8 @@ impl Table for FuseTable { #[minitrace::trace(name = "fuse_table_truncate")] #[async_backtrace::framed] - async fn truncate(&self, ctx: Arc) -> Result<()> { - self.do_truncate(ctx).await + async fn truncate(&self, ctx: Arc, purge: bool) -> Result<()> { + self.do_truncate(ctx, purge).await } #[minitrace::trace(name = "fuse_table_optimize")] diff --git a/src/query/storages/fuse/src/io/read/block/block_reader_parquet_deserialize.rs b/src/query/storages/fuse/src/io/read/block/block_reader_parquet_deserialize.rs index e83767533c59..1c7a8528965b 100644 --- a/src/query/storages/fuse/src/io/read/block/block_reader_parquet_deserialize.rs +++ b/src/query/storages/fuse/src/io/read/block/block_reader_parquet_deserialize.rs @@ -336,7 +336,7 @@ impl BlockReader { Suppose the name of table is T ~~~ create table tmp_t as select * from T; - drop table T; + drop table T all; alter table tmp_t rename to T; ~~~ Please note that the history of table T WILL BE LOST. diff --git a/src/query/storages/fuse/src/operations/delete.rs b/src/query/storages/fuse/src/operations/delete.rs index d92faa19b428..e08ef24f1dce 100644 --- a/src/query/storages/fuse/src/operations/delete.rs +++ b/src/query/storages/fuse/src/operations/delete.rs @@ -99,7 +99,8 @@ impl FuseTable { }; ctx.get_write_progress().incr(&progress_values); // deleting the whole table... just a truncate - return self.do_truncate(ctx.clone()).await.map(|_| None); + let purge = false; + return self.do_truncate(ctx.clone(), purge).await.map(|_| None); } Some(filters) => filters, }; @@ -121,7 +122,8 @@ impl FuseTable { ctx.get_write_progress().incr(&progress_values); // deleting the whole table... just a truncate - return self.do_truncate(ctx.clone()).await.map(|_| None); + let purge = false; + return self.do_truncate(ctx.clone(), purge).await.map(|_| None); } } Ok(Some(snapshot.clone())) diff --git a/src/query/storages/fuse/src/operations/truncate.rs b/src/query/storages/fuse/src/operations/truncate.rs index 540b714df832..2685d8c6093f 100644 --- a/src/query/storages/fuse/src/operations/truncate.rs +++ b/src/query/storages/fuse/src/operations/truncate.rs @@ -30,7 +30,7 @@ use crate::FuseTable; impl FuseTable { #[inline] #[async_backtrace::framed] - pub async fn do_truncate(&self, ctx: Arc) -> Result<()> { + pub async fn do_truncate(&self, ctx: Arc, purge: bool) -> Result<()> { if let Some(prev_snapshot) = self.read_table_snapshot().await? { // 1. prepare new snapshot let prev_id = prev_snapshot.snapshot_id; @@ -97,6 +97,23 @@ impl FuseTable { new_snapshot_loc, ) .await; + + // best effort to remove historical data. if failed, let `vacuum` to do the job. + // TODO: consider remove the `purge` option from `truncate` + // - it is not a safe operation, there is NO retention interval protection here + // - it is incompatible with time travel features + if purge { + let snapshot_files = self.list_snapshot_files().await?; + let keep_last_snapshot = false; + let ret = self + .do_purge(&ctx, snapshot_files, None, keep_last_snapshot, false) + .await; + if let Err(e) = ret { + return Err(e); + } else { + return Ok(()); + } + } } Ok(()) diff --git a/src/query/storages/hive/hive/src/hive_table.rs b/src/query/storages/hive/hive/src/hive_table.rs index bcb31d05f0cf..001cd227a3ce 100644 --- a/src/query/storages/hive/hive/src/hive_table.rs +++ b/src/query/storages/hive/hive/src/hive_table.rs @@ -602,7 +602,7 @@ impl Table for HiveTable { } #[async_backtrace::framed] - async fn truncate(&self, _ctx: Arc) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: bool) -> Result<()> { Err(ErrorCode::Unimplemented(format!( "truncate for table {} is not implemented", self.name() diff --git a/src/query/storages/memory/src/memory_table.rs b/src/query/storages/memory/src/memory_table.rs index 8605eb97e35f..43e1ef1fc7e8 100644 --- a/src/query/storages/memory/src/memory_table.rs +++ b/src/query/storages/memory/src/memory_table.rs @@ -262,7 +262,7 @@ impl Table for MemoryTable { } #[async_backtrace::framed] - async fn truncate(&self, _ctx: Arc) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: bool) -> Result<()> { let mut blocks = self.blocks.write(); blocks.clear(); Ok(()) diff --git a/src/query/storages/stage/src/stage_table.rs b/src/query/storages/stage/src/stage_table.rs index b28307ee5aca..62a04cd5f975 100644 --- a/src/query/storages/stage/src/stage_table.rs +++ b/src/query/storages/stage/src/stage_table.rs @@ -275,7 +275,7 @@ impl Table for StageTable { // Truncate the stage file. #[async_backtrace::framed] - async fn truncate(&self, _ctx: Arc) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: bool) -> Result<()> { Err(ErrorCode::Unimplemented( "S3 external table truncate() unimplemented yet!", )) diff --git a/src/query/storages/system/src/log_queue.rs b/src/query/storages/system/src/log_queue.rs index 9a4dc18550c7..748623ca3cf2 100644 --- a/src/query/storages/system/src/log_queue.rs +++ b/src/query/storages/system/src/log_queue.rs @@ -215,7 +215,7 @@ impl Table for SystemLogTable { } #[async_backtrace::framed] - async fn truncate(&self, _ctx: Arc) -> Result<()> { + async fn truncate(&self, _ctx: Arc, _: bool) -> Result<()> { let log_queue = SystemLogQueue::::instance()?; let mut write_guard = log_queue.data.write(); diff --git a/src/query/storages/system/src/table.rs b/src/query/storages/system/src/table.rs index 55dbfb8648e5..8d01a1c0f3d6 100644 --- a/src/query/storages/system/src/table.rs +++ b/src/query/storages/system/src/table.rs @@ -149,7 +149,7 @@ impl Table for SyncOneBlockSystemTable) -> Result<()> { + async fn truncate(&self, ctx: Arc, _purge: bool) -> Result<()> { self.inner_table.truncate(ctx) } diff --git a/src/tests/sqlsmith/src/sql_gen/ddl.rs b/src/tests/sqlsmith/src/sql_gen/ddl.rs index c91329af1d63..ef981e2b8463 100644 --- a/src/tests/sqlsmith/src/sql_gen/ddl.rs +++ b/src/tests/sqlsmith/src/sql_gen/ddl.rs @@ -66,6 +66,7 @@ impl<'a, R: Rng> SqlGenerator<'a, R> { catalog: None, database: None, table: Identifier::from_name(table_name.clone()), + all: false, }; let create_table = CreateTableStmt { if_not_exists: true, diff --git a/tests/sqllogictests/suites/base/01_system/01_0002_system_query_log b/tests/sqllogictests/suites/base/01_system/01_0002_system_query_log index 82ce2774d1d8..9ec8305f11df 100644 --- a/tests/sqllogictests/suites/base/01_system/01_0002_system_query_log +++ b/tests/sqllogictests/suites/base/01_system/01_0002_system_query_log @@ -12,7 +12,7 @@ select count(*) > 0 from system.query_log 1 statement ok -drop table if exists tbl_01_0002 +drop table if exists tbl_01_0002 all statement ok create table tbl_01_0002(a int) diff --git a/tests/sqllogictests/suites/base/01_system/01_0007_system_clustering_history b/tests/sqllogictests/suites/base/01_system/01_0007_system_clustering_history index 1072cd21c742..0294adf01e81 100644 --- a/tests/sqllogictests/suites/base/01_system/01_0007_system_clustering_history +++ b/tests/sqllogictests/suites/base/01_system/01_0007_system_clustering_history @@ -1,5 +1,5 @@ statement ok -drop table if exists tbl_01_0007 +drop table if exists tbl_01_0007 all statement ok create table tbl_01_0007(a int not null) cluster by(a) diff --git a/tests/sqllogictests/suites/base/03_common/03_0003_select_group_by b/tests/sqllogictests/suites/base/03_common/03_0003_select_group_by index 602cf6039f5d..5a57592d690f 100644 --- a/tests/sqllogictests/suites/base/03_common/03_0003_select_group_by +++ b/tests/sqllogictests/suites/base/03_common/03_0003_select_group_by @@ -75,7 +75,7 @@ statement ok DROP table t statement ok -drop table if exists t_datetime +drop table if exists t_datetime all statement ok CREATE TABLE t_datetime(created_at Date, created_time DateTime, count Int32) diff --git a/tests/sqllogictests/suites/base/03_common/03_0025_delete_from b/tests/sqllogictests/suites/base/03_common/03_0025_delete_from index ec371b908bba..692e4f549964 100644 --- a/tests/sqllogictests/suites/base/03_common/03_0025_delete_from +++ b/tests/sqllogictests/suites/base/03_common/03_0025_delete_from @@ -54,7 +54,7 @@ select count(*) = 0 from t statement ok -drop table t +drop table t all statement ok create table t (c Int null) @@ -141,7 +141,7 @@ select count(*) = 0 from t statement ok -drop table t +drop table t all statement ok create table t(c Int) CLUSTER BY(c+1) @@ -161,7 +161,7 @@ select count(*) = 2 from t 1 statement ok -drop table t +drop table t all statement ok create table t(a Int, b Int) @@ -186,7 +186,7 @@ statement ok delete from t where t.a in (select * from numbers(10)) statement ok -drop table t +drop table t all #################################### @@ -245,7 +245,7 @@ select * from t order by c; statement ok -drop table t +drop table t all #################################### # delete pruning, whole segments # @@ -279,7 +279,7 @@ select * from t order by c; 9 statement ok -drop table t +drop table t all # test large data statement ok @@ -319,7 +319,7 @@ select count(*) from t where c >= 0 and c < 1500000; 0 statement ok -drop table t +drop table t all statement ok DROP DATABASE db1 diff --git a/tests/sqllogictests/suites/base/03_common/03_0028_copy_into_stage b/tests/sqllogictests/suites/base/03_common/03_0028_copy_into_stage index c0c942e443cb..0ee2e7040cdb 100644 --- a/tests/sqllogictests/suites/base/03_common/03_0028_copy_into_stage +++ b/tests/sqllogictests/suites/base/03_common/03_0028_copy_into_stage @@ -31,7 +31,7 @@ SELECT COUNT() FROM test_table 4 statement ok -drop table test_table +drop table test_table all statement ok drop stage test diff --git a/tests/sqllogictests/suites/base/03_common/03_0031_copy_into_user_stage b/tests/sqllogictests/suites/base/03_common/03_0031_copy_into_user_stage index 462da395ef8e..6dee4c9f4fdf 100644 --- a/tests/sqllogictests/suites/base/03_common/03_0031_copy_into_user_stage +++ b/tests/sqllogictests/suites/base/03_common/03_0031_copy_into_user_stage @@ -28,7 +28,7 @@ SELECT COUNT() FROM test_table 4 statement ok -drop table test_table +drop table test_table all statement ok DROP DATABASE db1 diff --git a/tests/sqllogictests/suites/base/03_common/03_0035_update b/tests/sqllogictests/suites/base/03_common/03_0035_update index f347f054432a..25d88b78d7d6 100644 --- a/tests/sqllogictests/suites/base/03_common/03_0035_update +++ b/tests/sqllogictests/suites/base/03_common/03_0035_update @@ -89,13 +89,13 @@ select a from t3 6 statement ok -drop table t1 +drop table t1 all statement ok -drop table t2 +drop table t2 all statement ok -drop table t3 +drop table t3 all statement ok create table t1(id1 int, val1 varchar(255)); diff --git a/tests/sqllogictests/suites/base/05_ddl/05_0001_ddl_drop_table_full b/tests/sqllogictests/suites/base/05_ddl/05_0001_ddl_drop_table_full index 35cf934d75ed..5be01f171242 100644 --- a/tests/sqllogictests/suites/base/05_ddl/05_0001_ddl_drop_table_full +++ b/tests/sqllogictests/suites/base/05_ddl/05_0001_ddl_drop_table_full @@ -11,13 +11,13 @@ statement ok CREATE TABLE t(c1 int) ENGINE = Null statement ok -DROP TABLE t +DROP TABLE t ALL statement ok CREATE TABLE t(c1 int) ENGINE = Fuse statement ok -DROP TABLE t +DROP TABLE t ALL statement ok DROP database db_13_0001 diff --git a/tests/sqllogictests/suites/base/05_ddl/05_0023_exists_table b/tests/sqllogictests/suites/base/05_ddl/05_0023_exists_table index 80bcb8cbfe49..971e21f68fbc 100644 --- a/tests/sqllogictests/suites/base/05_ddl/05_0023_exists_table +++ b/tests/sqllogictests/suites/base/05_ddl/05_0023_exists_table @@ -23,7 +23,7 @@ statement ok EXISTS TABLE db_05_0023_v2.t statement ok -DROP TABLE t +DROP TABLE t ALL statement ok EXISTS TABLE db_05_0023_v2.t diff --git a/tests/sqllogictests/suites/base/09_fuse_engine/09_0006_func_fuse_history b/tests/sqllogictests/suites/base/09_fuse_engine/09_0006_func_fuse_history index 74caa07f7c9a..522df13c0f26 100644 --- a/tests/sqllogictests/suites/base/09_fuse_engine/09_0006_func_fuse_history +++ b/tests/sqllogictests/suites/base/09_fuse_engine/09_0006_func_fuse_history @@ -81,7 +81,7 @@ select count() from fuse_block('db_09_0006', 't1') 5 statement ok -truncate table t1 +truncate table t1 purge query I select block_size from fuse_block('db_09_0006', 't1') diff --git a/tests/sqllogictests/suites/base/09_fuse_engine/09_0007_func_fuse_truncate b/tests/sqllogictests/suites/base/09_fuse_engine/09_0007_func_fuse_truncate_purge similarity index 95% rename from tests/sqllogictests/suites/base/09_fuse_engine/09_0007_func_fuse_truncate rename to tests/sqllogictests/suites/base/09_fuse_engine/09_0007_func_fuse_truncate_purge index 0af63cefa0bc..54d0d969018c 100644 --- a/tests/sqllogictests/suites/base/09_fuse_engine/09_0007_func_fuse_truncate +++ b/tests/sqllogictests/suites/base/09_fuse_engine/09_0007_func_fuse_truncate_purge @@ -25,12 +25,12 @@ select count(*) from fuse_snapshot('db_09_0007', 't') 3 statement ok -truncate table `t` +truncate table `t` purge query I select count(*) from fuse_snapshot('db_09_0007', 't') ---- -4 +1 statement ok select * from t diff --git a/tests/sqllogictests/suites/base/09_fuse_engine/09_0016_remote_alter_recluster b/tests/sqllogictests/suites/base/09_fuse_engine/09_0016_remote_alter_recluster index b65f946d7aeb..367af1a8242c 100644 --- a/tests/sqllogictests/suites/base/09_fuse_engine/09_0016_remote_alter_recluster +++ b/tests/sqllogictests/suites/base/09_fuse_engine/09_0016_remote_alter_recluster @@ -82,7 +82,7 @@ select average_overlaps, average_depth, block_depth_histogram from clustering_in # test trim string statement ok -truncate table t3 +truncate table t3 purge statement ok insert into t3 values(1,'123456780'),(2,'123456781') diff --git a/tests/sqllogictests/suites/base/09_fuse_engine/09_0017_transient_table b/tests/sqllogictests/suites/base/09_fuse_engine/09_0017_transient_table index 52d2b201306b..50a3db5b52a0 100644 --- a/tests/sqllogictests/suites/base/09_fuse_engine/09_0017_transient_table +++ b/tests/sqllogictests/suites/base/09_fuse_engine/09_0017_transient_table @@ -38,3 +38,4 @@ DROP TABLE t09_0016 statement ok DROP DATABASE db1 + diff --git a/tests/sqllogictests/suites/base/12_time_travel/12_0003_time_travel_undrop b/tests/sqllogictests/suites/base/12_time_travel/12_0003_time_travel_undrop index 50acc17bf61c..0f0609ace3e8 100644 --- a/tests/sqllogictests/suites/base/12_time_travel/12_0003_time_travel_undrop +++ b/tests/sqllogictests/suites/base/12_time_travel/12_0003_time_travel_undrop @@ -103,5 +103,22 @@ SELECT count(1) FROM t statement ok DROP TABLE t +statement ok +CREATE TABLE t(c int) + +statement ok +INSERT INTO t values(1) + +statement ok +DROP TABLE t ALL + +statement ok +UNDROP TABLE t + +query I +SELECT count(*) FROM t +---- +0 + statement ok DROP database db_12_0003 diff --git a/tests/sqllogictests/suites/base/issues/issue_10103.test b/tests/sqllogictests/suites/base/issues/issue_10103.test index 3be0dad32034..f617f68c50e8 100644 --- a/tests/sqllogictests/suites/base/issues/issue_10103.test +++ b/tests/sqllogictests/suites/base/issues/issue_10103.test @@ -34,10 +34,10 @@ SELECT ts FROM test_ts_table LIMIT 1 2023-02-19 11:18:01.000000 statement ok -drop table test_table +drop table test_table all statement ok -drop table test_ts_table +drop table test_ts_table all statement ok drop stage test_10103 diff --git a/tests/sqllogictests/suites/duckdb/sql/aggregate/group/group_by_grouping_sets.test b/tests/sqllogictests/suites/duckdb/sql/aggregate/group/group_by_grouping_sets.test index 4bfb3f29314e..e19ae1bf808e 100644 --- a/tests/sqllogictests/suites/duckdb/sql/aggregate/group/group_by_grouping_sets.test +++ b/tests/sqllogictests/suites/duckdb/sql/aggregate/group/group_by_grouping_sets.test @@ -245,10 +245,10 @@ a B 1 5 NULL B a A 1 5 NULL NULL statement ok -drop table t; +drop table t all; statement ok -drop table tt; +drop table tt all; statement ok drop database grouping_sets; diff --git a/tests/sqllogictests/suites/mode/cluster/04_0002_explain_v2.test b/tests/sqllogictests/suites/mode/cluster/04_0002_explain_v2.test index 3c7300f00ddd..c48c284d5f33 100644 --- a/tests/sqllogictests/suites/mode/cluster/04_0002_explain_v2.test +++ b/tests/sqllogictests/suites/mode/cluster/04_0002_explain_v2.test @@ -2,10 +2,10 @@ statement ok set prefer_broadcast_join = 0 statement ok -drop table if exists t1; +drop table if exists t1 all; statement ok -drop table if exists t2; +drop table if exists t2 all; statement ok create table t1(a int not null, b int not null); diff --git a/tests/sqllogictests/suites/mode/standalone/explain/explain.test b/tests/sqllogictests/suites/mode/standalone/explain/explain.test index 6a3bff0473b1..d800c2ed23bb 100644 --- a/tests/sqllogictests/suites/mode/standalone/explain/explain.test +++ b/tests/sqllogictests/suites/mode/standalone/explain/explain.test @@ -1,8 +1,8 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok -drop table if exists t2 +drop table if exists t2 all statement ok create table t1 as select number as a, number as b from numbers(1) diff --git a/tests/sqllogictests/suites/mode/standalone/explain_native/explain.test b/tests/sqllogictests/suites/mode/standalone/explain_native/explain.test index 0a9cbd5809df..bd2f6f0459d6 100644 --- a/tests/sqllogictests/suites/mode/standalone/explain_native/explain.test +++ b/tests/sqllogictests/suites/mode/standalone/explain_native/explain.test @@ -1,8 +1,8 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok -drop table if exists t2 +drop table if exists t2 all statement ok create table t1 as select number as a, number as b from numbers(1) diff --git a/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes b/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes index 646c3355004e..9f9607c8c2e6 100644 --- a/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes +++ b/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes @@ -1,5 +1,5 @@ statement ok -drop table if exists t +drop table if exists t all statement ok set timezone = 'UTC' diff --git a/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes_tz b/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes_tz index cd751f969ee3..765c124cbf74 100644 --- a/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes_tz +++ b/tests/sqllogictests/suites/query/02_function/02_0012_function_datetimes_tz @@ -1,5 +1,5 @@ statement ok -drop table if exists tt +drop table if exists tt all statement ok set timezone='UTC' diff --git a/tests/sqllogictests/suites/query/02_function/02_0014_function_maths b/tests/sqllogictests/suites/query/02_function/02_0014_function_maths index 6325dc32dbbc..e88a7c4cb3f7 100644 --- a/tests/sqllogictests/suites/query/02_function/02_0014_function_maths +++ b/tests/sqllogictests/suites/query/02_function/02_0014_function_maths @@ -1,5 +1,5 @@ statement ok -drop table if exists math_sample_numbers +drop table if exists math_sample_numbers all statement ok CREATE TABLE math_sample_numbers (timestamp UInt32, value Int32) Engine = Fuse diff --git a/tests/sqllogictests/suites/query/02_function/02_0018_function_strings_repeat b/tests/sqllogictests/suites/query/02_function/02_0018_function_strings_repeat index 7e6bcdbafe20..a2c3ba90ad7e 100644 --- a/tests/sqllogictests/suites/query/02_function/02_0018_function_strings_repeat +++ b/tests/sqllogictests/suites/query/02_function/02_0018_function_strings_repeat @@ -1,14 +1,14 @@ statement ok -drop table if exists strings_repeat_sample_u8 +drop table if exists strings_repeat_sample_u8 all statement ok -drop table if exists strings_repeat_sample_u16 +drop table if exists strings_repeat_sample_u16 all statement ok -drop table if exists strings_repeat_sample_u32 +drop table if exists strings_repeat_sample_u32 all statement ok -drop table if exists strings_repeat_sample_u64 +drop table if exists strings_repeat_sample_u64 all statement ok CREATE TABLE strings_repeat_sample_u8(s String, n Uint8) Engine = Fuse diff --git a/tests/sqllogictests/suites/query/02_function/02_0048_function_semi_structureds_object_keys b/tests/sqllogictests/suites/query/02_function/02_0048_function_semi_structureds_object_keys index af71632ed5ce..d475a1a6839c 100644 --- a/tests/sqllogictests/suites/query/02_function/02_0048_function_semi_structureds_object_keys +++ b/tests/sqllogictests/suites/query/02_function/02_0048_function_semi_structureds_object_keys @@ -1,5 +1,5 @@ statement ok -drop table if exists objects_test1 +drop table if exists objects_test1 all statement ok CREATE TABLE IF NOT EXISTS objects_test1(id TINYINT, obj VARIANT, var VARIANT) Engine = Fuse diff --git a/tests/sqllogictests/suites/query/cte.test b/tests/sqllogictests/suites/query/cte.test index 9df89c397fc6..4ffcf46b2de4 100644 --- a/tests/sqllogictests/suites/query/cte.test +++ b/tests/sqllogictests/suites/query/cte.test @@ -2,7 +2,7 @@ statement ok use default statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer, b integer, c integer, d integer, e integer) diff --git a/tests/sqllogictests/suites/query/render_result.test b/tests/sqllogictests/suites/query/render_result.test index bfb960bf447c..aef7151accd1 100644 --- a/tests/sqllogictests/suites/query/render_result.test +++ b/tests/sqllogictests/suites/query/render_result.test @@ -2,7 +2,7 @@ statement ok use default statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer, b integer, c integer, d integer, e integer) @@ -30,4 +30,4 @@ order by col1,col5,col3,col2,col4 106 1 333 1067 109 statement ok -drop table if exists t1 +drop table if exists t1 all diff --git a/tests/sqllogictests/suites/ydb/select1-1.test b/tests/sqllogictests/suites/ydb/select1-1.test index 0d0390458591..766b45362807 100644 --- a/tests/sqllogictests/suites/ydb/select1-1.test +++ b/tests/sqllogictests/suites/ydb/select1-1.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer, b integer, c integer, d integer, e integer) diff --git a/tests/sqllogictests/suites/ydb/select1-2.test b/tests/sqllogictests/suites/ydb/select1-2.test index 6093d3b5d977..b8eb36808143 100644 --- a/tests/sqllogictests/suites/ydb/select1-2.test +++ b/tests/sqllogictests/suites/ydb/select1-2.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer, b integer, c integer, d integer, e integer) diff --git a/tests/sqllogictests/suites/ydb/select1-3.test b/tests/sqllogictests/suites/ydb/select1-3.test index 7ebd1a7dc9fa..4d3b407c6f04 100644 --- a/tests/sqllogictests/suites/ydb/select1-3.test +++ b/tests/sqllogictests/suites/ydb/select1-3.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer, b integer, c integer, d integer, e integer) diff --git a/tests/sqllogictests/suites/ydb/select1-4.test b/tests/sqllogictests/suites/ydb/select1-4.test index b6906faa30d2..49a214f8502e 100644 --- a/tests/sqllogictests/suites/ydb/select1-4.test +++ b/tests/sqllogictests/suites/ydb/select1-4.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer, b integer, c integer, d integer, e integer) diff --git a/tests/sqllogictests/suites/ydb/select1-5.test b/tests/sqllogictests/suites/ydb/select1-5.test index dcf4708612d2..4be2a249bfe1 100644 --- a/tests/sqllogictests/suites/ydb/select1-5.test +++ b/tests/sqllogictests/suites/ydb/select1-5.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer, b integer, c integer, d integer, e integer) diff --git a/tests/sqllogictests/suites/ydb/select2-1.test b/tests/sqllogictests/suites/ydb/select2-1.test index 9b45f459106e..36cf9b00c8e9 100644 --- a/tests/sqllogictests/suites/ydb/select2-1.test +++ b/tests/sqllogictests/suites/ydb/select2-1.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select2-2.test b/tests/sqllogictests/suites/ydb/select2-2.test index 3ff660a15473..9d5471946805 100644 --- a/tests/sqllogictests/suites/ydb/select2-2.test +++ b/tests/sqllogictests/suites/ydb/select2-2.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select2-3.test b/tests/sqllogictests/suites/ydb/select2-3.test index 3309b5d1b6b8..8261386c5567 100644 --- a/tests/sqllogictests/suites/ydb/select2-3.test +++ b/tests/sqllogictests/suites/ydb/select2-3.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select2-4.test b/tests/sqllogictests/suites/ydb/select2-4.test index 2161ba020978..0cf264950b1f 100644 --- a/tests/sqllogictests/suites/ydb/select2-4.test +++ b/tests/sqllogictests/suites/ydb/select2-4.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select2-5.test b/tests/sqllogictests/suites/ydb/select2-5.test index 10b98ba17e16..c992d31c3c2d 100644 --- a/tests/sqllogictests/suites/ydb/select2-5.test +++ b/tests/sqllogictests/suites/ydb/select2-5.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-1.test b/tests/sqllogictests/suites/ydb/select3-1.test index 073074374831..22456c0cd6c9 100644 --- a/tests/sqllogictests/suites/ydb/select3-1.test +++ b/tests/sqllogictests/suites/ydb/select3-1.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-10.test b/tests/sqllogictests/suites/ydb/select3-10.test index c1f1216ab432..9866756f8909 100644 --- a/tests/sqllogictests/suites/ydb/select3-10.test +++ b/tests/sqllogictests/suites/ydb/select3-10.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-11.test b/tests/sqllogictests/suites/ydb/select3-11.test index e3e6d6b63fd7..1a446a863362 100644 --- a/tests/sqllogictests/suites/ydb/select3-11.test +++ b/tests/sqllogictests/suites/ydb/select3-11.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-12.test b/tests/sqllogictests/suites/ydb/select3-12.test index 708709884737..041169ab4421 100644 --- a/tests/sqllogictests/suites/ydb/select3-12.test +++ b/tests/sqllogictests/suites/ydb/select3-12.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-13.test b/tests/sqllogictests/suites/ydb/select3-13.test index ae77d1da8322..4f0d2d708804 100644 --- a/tests/sqllogictests/suites/ydb/select3-13.test +++ b/tests/sqllogictests/suites/ydb/select3-13.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-14.test b/tests/sqllogictests/suites/ydb/select3-14.test index 1b62d6d12f15..223a247e9df1 100644 --- a/tests/sqllogictests/suites/ydb/select3-14.test +++ b/tests/sqllogictests/suites/ydb/select3-14.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-15.test b/tests/sqllogictests/suites/ydb/select3-15.test index cf6c1fab47d2..4c814cf69207 100644 --- a/tests/sqllogictests/suites/ydb/select3-15.test +++ b/tests/sqllogictests/suites/ydb/select3-15.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-2.test b/tests/sqllogictests/suites/ydb/select3-2.test index f5e46aca3f4a..e6b89c287891 100644 --- a/tests/sqllogictests/suites/ydb/select3-2.test +++ b/tests/sqllogictests/suites/ydb/select3-2.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-3.test b/tests/sqllogictests/suites/ydb/select3-3.test index feb46d3a94db..bd6c1fcaa9aa 100644 --- a/tests/sqllogictests/suites/ydb/select3-3.test +++ b/tests/sqllogictests/suites/ydb/select3-3.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-4.test b/tests/sqllogictests/suites/ydb/select3-4.test index e3dd6076aa0a..0ff745810507 100644 --- a/tests/sqllogictests/suites/ydb/select3-4.test +++ b/tests/sqllogictests/suites/ydb/select3-4.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-5.test b/tests/sqllogictests/suites/ydb/select3-5.test index a9913c947404..259d23e75d5b 100644 --- a/tests/sqllogictests/suites/ydb/select3-5.test +++ b/tests/sqllogictests/suites/ydb/select3-5.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-6.test b/tests/sqllogictests/suites/ydb/select3-6.test index 312d01a101a1..4877d8876609 100644 --- a/tests/sqllogictests/suites/ydb/select3-6.test +++ b/tests/sqllogictests/suites/ydb/select3-6.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-7.test b/tests/sqllogictests/suites/ydb/select3-7.test index 477e9ea78503..a2e5a8d5ddaa 100644 --- a/tests/sqllogictests/suites/ydb/select3-7.test +++ b/tests/sqllogictests/suites/ydb/select3-7.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-8.test b/tests/sqllogictests/suites/ydb/select3-8.test index 855703744f49..37e3828f498c 100644 --- a/tests/sqllogictests/suites/ydb/select3-8.test +++ b/tests/sqllogictests/suites/ydb/select3-8.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/sqllogictests/suites/ydb/select3-9.test b/tests/sqllogictests/suites/ydb/select3-9.test index 01b582ab3fa2..f42942c264d9 100644 --- a/tests/sqllogictests/suites/ydb/select3-9.test +++ b/tests/sqllogictests/suites/ydb/select3-9.test @@ -1,5 +1,5 @@ statement ok -drop table if exists t1 +drop table if exists t1 all statement ok create table t1(a integer null, b integer null, c integer null, d integer null, e integer null) diff --git a/tests/suites/0_stateless/17_altertable/17_0002_alter_table_purge_before.sh b/tests/suites/0_stateless/17_altertable/17_0002_alter_table_purge_before.sh index 93644ecfd07d..85f385032306 100755 --- a/tests/suites/0_stateless/17_altertable/17_0002_alter_table_purge_before.sh +++ b/tests/suites/0_stateless/17_altertable/17_0002_alter_table_purge_before.sh @@ -46,7 +46,7 @@ echo "checking that after purge (by snapshot id) there should be 4 rows left" echo "select count(*)=4 from t17_0002" | $MYSQL_CLIENT_CONNECT ## Drop table. -echo "drop table t17_0002" | $MYSQL_CLIENT_CONNECT +echo "drop table t17_0002 all" | $MYSQL_CLIENT_CONNECT # PURGE BEFORE TIMESTAMP @@ -90,4 +90,4 @@ echo "checking that after purge (by timestamp) there should be 5 rows left" echo "select count(*)=5 from t17_0002" | $MYSQL_CLIENT_CONNECT ## Drop table. -echo "drop table t17_0002" | $MYSQL_CLIENT_CONNECT +echo "drop table t17_0002 all" | $MYSQL_CLIENT_CONNECT diff --git a/tests/suites/0_stateless/17_altertable/17_0003_alter_table_update.sh b/tests/suites/0_stateless/17_altertable/17_0003_alter_table_update.sh index 583cfb563b3a..fa884b01df13 100755 --- a/tests/suites/0_stateless/17_altertable/17_0003_alter_table_update.sh +++ b/tests/suites/0_stateless/17_altertable/17_0003_alter_table_update.sh @@ -25,7 +25,7 @@ echo "update table column" echo "update t17_0003 set c=2 where c=1" | $MYSQL_CLIENT_CONNECT ## Drop table. -echo "drop table t17_0003" | $MYSQL_CLIENT_CONNECT +echo "drop table t17_0003 all" | $MYSQL_CLIENT_CONNECT ## create two column table echo "create table t17_0003(a int not null, b int not null)" | $MYSQL_CLIENT_CONNECT @@ -50,4 +50,4 @@ echo "update table column" echo "update t17_0003 set a=3 where a=1" | $MYSQL_CLIENT_CONNECT ## Drop table. -echo "drop table t17_0003" | $MYSQL_CLIENT_CONNECT +echo "drop table t17_0003 all" | $MYSQL_CLIENT_CONNECT \ No newline at end of file diff --git a/tests/suites/0_stateless/20+_others/20_0011_purge_before.sh b/tests/suites/0_stateless/20+_others/20_0011_purge_before.sh index 49d136e729c4..4980aa0d9885 100755 --- a/tests/suites/0_stateless/20+_others/20_0011_purge_before.sh +++ b/tests/suites/0_stateless/20+_others/20_0011_purge_before.sh @@ -31,7 +31,7 @@ echo "checking that after purge (by snapshot id) there should be 4 rows left" echo "select count(*)=4 from t20_0011" | $MYSQL_CLIENT_CONNECT ## Drop table. -echo "drop table t20_0011" | $MYSQL_CLIENT_CONNECT +echo "drop table t20_0011 all" | $MYSQL_CLIENT_CONNECT # PURGE BEFORE TIMESTAMP @@ -58,4 +58,4 @@ echo "checking that after purge (by timestamp) there should be 4 rows left" echo "select count(*)=4 from t20_0011" | $MYSQL_CLIENT_CONNECT ## Drop table. -echo "drop table t20_0011" | $MYSQL_CLIENT_CONNECT +echo "drop table t20_0011 all" | $MYSQL_CLIENT_CONNECT diff --git a/tests/suites/0_stateless/20+_others/20_0012_privilege_access.sh b/tests/suites/0_stateless/20+_others/20_0012_privilege_access.sh index c766b6005b5b..134e1f1c5efd 100755 --- a/tests/suites/0_stateless/20+_others/20_0012_privilege_access.sh +++ b/tests/suites/0_stateless/20+_others/20_0012_privilege_access.sh @@ -113,9 +113,9 @@ echo "GRANT SELECT ON system.fuse_block TO 'test-user'" | $MYSQL_CLIENT_CONNECT echo "select count(*)>=1 from fuse_block('default', 't20_0012_a')" | $TEST_USER_CONNECT ## Drop table. -echo "drop table default.t20_0012" | $MYSQL_CLIENT_CONNECT -echo "drop table default.t20_0012_a" | $MYSQL_CLIENT_CONNECT -echo "drop table default.t20_0012_b" | $MYSQL_CLIENT_CONNECT +echo "drop table default.t20_0012 all" | $MYSQL_CLIENT_CONNECT +echo "drop table default.t20_0012_a all" | $MYSQL_CLIENT_CONNECT +echo "drop table default.t20_0012_b all" | $MYSQL_CLIENT_CONNECT echo "drop view default2.v_t20_0012" | $MYSQL_CLIENT_CONNECT ## Drop database. diff --git a/tests/suites/1_stateful/04_mini_dataset/04_0000_mini_ontime.sh b/tests/suites/1_stateful/04_mini_dataset/04_0000_mini_ontime.sh index acf4a58613f7..707acc4db0d0 100755 --- a/tests/suites/1_stateful/04_mini_dataset/04_0000_mini_ontime.sh +++ b/tests/suites/1_stateful/04_mini_dataset/04_0000_mini_ontime.sh @@ -28,4 +28,4 @@ for i in "${ontime_statements[@]}"; do done ## Clean table -echo "drop table if exists ontime_mini;" | $MYSQL_CLIENT_CONNECT +echo "drop table if exists ontime_mini all;" | $MYSQL_CLIENT_CONNECT diff --git a/tests/suites/1_stateful/04_mini_dataset/04_0001_mini_hits.sh b/tests/suites/1_stateful/04_mini_dataset/04_0001_mini_hits.sh index e5a7e3ffa244..291ad00c80f2 100755 --- a/tests/suites/1_stateful/04_mini_dataset/04_0001_mini_hits.sh +++ b/tests/suites/1_stateful/04_mini_dataset/04_0001_mini_hits.sh @@ -105,4 +105,4 @@ for i in "${hits_statements[@]}"; do done ## Clean up -echo "drop table if exists hits;" | $MYSQL_CLIENT_CONNECT +echo "drop table if exists hits all;" | $MYSQL_CLIENT_CONNECT diff --git a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_00_load_compact_copy.sh b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_00_load_compact_copy.sh index be21f27434c9..bd847a61660b 100755 --- a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_00_load_compact_copy.sh +++ b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_00_load_compact_copy.sh @@ -10,7 +10,7 @@ for j in $(seq 1 1000);do printf "0123456789\n" >> "$DATA" done -echo "drop table if exists t1" | $MYSQL_CLIENT_CONNECT +echo "drop table if exists t1 all" | $MYSQL_CLIENT_CONNECT echo "CREATE TABLE t1 ( c0 string diff --git a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_01_load_compact_streaming_load.sh b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_01_load_compact_streaming_load.sh index ef82801b4435..2b37912014b9 100755 --- a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_01_load_compact_streaming_load.sh +++ b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_01_load_compact_streaming_load.sh @@ -10,7 +10,7 @@ for j in $(seq 1 1000);do printf "0123456789\n" >> "$DATA" done -echo "drop table if exists t1" | $MYSQL_CLIENT_CONNECT +echo "drop table if exists t1 all" | $MYSQL_CLIENT_CONNECT echo "CREATE TABLE t1 ( c0 string diff --git a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_max_size.sh b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_max_size.sh index 2c2a0c6ebda1..4f9c131b9a89 100755 --- a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_max_size.sh +++ b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_max_size.sh @@ -11,7 +11,7 @@ for j in $(seq 1 1000);do printf "0123456789\n" >> "$DATA" done -echo "drop table if exists t1" | $MYSQL_CLIENT_CONNECT +echo "drop table if exists t1 all" | $MYSQL_CLIENT_CONNECT echo "CREATE TABLE t1 ( c0 string diff --git a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_row_per_block.sh b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_row_per_block.sh index 9f8fdbfd8c1d..087fbcd550bf 100755 --- a/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_row_per_block.sh +++ b/tests/suites/1_stateful/05_formats/05_01_compact/05_01_02_load_compact_copy_row_per_block.sh @@ -11,7 +11,7 @@ for j in $(seq 1 1000);do printf "0123456789\n" >> "$DATA" done -echo "drop table if exists t1" | $MYSQL_CLIENT_CONNECT +echo "drop table if exists t1 all" | $MYSQL_CLIENT_CONNECT echo "CREATE TABLE t1 ( c0 string