diff --git a/src/Storages/System/StorageSystemDroppedTablesProjectionParts.h b/src/Storages/System/StorageSystemDroppedTablesProjectionParts.h new file mode 100644 index 00000000000..70616b686a8 --- /dev/null +++ b/src/Storages/System/StorageSystemDroppedTablesProjectionParts.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + + +namespace DB +{ + +class Context; + + +/** Implements system table 'dropped_tables_projection_parts' which allows to get information about data parts for dropped but not yet removed tables. + */ +class StorageSystemDroppedTablesProjectionParts final : public StorageSystemProjectionParts +{ +public: + explicit StorageSystemDroppedTablesProjectionParts(const StorageID & table_id) : StorageSystemProjectionParts(table_id) {} + + std::string getName() const override { return "SystemDroppedTablesProjectionParts"; } +protected: + std::unique_ptr getStoragesInfoStream(std::optional, std::optional filter, ContextPtr context) override + { + return std::make_unique(std::move(filter), context); + } +}; + +} diff --git a/src/Storages/System/StorageSystemProjectionParts.h b/src/Storages/System/StorageSystemProjectionParts.h index 71acc4426c1..99a94ea87cc 100644 --- a/src/Storages/System/StorageSystemProjectionParts.h +++ b/src/Storages/System/StorageSystemProjectionParts.h @@ -11,7 +11,7 @@ class Context; /** Implements system table 'projection_parts' which allows to get information about projection parts for tables of MergeTree family. */ -class StorageSystemProjectionParts final : public StorageSystemPartsBase +class StorageSystemProjectionParts : public StorageSystemPartsBase { public: explicit StorageSystemProjectionParts(const StorageID & table_id_); diff --git a/src/Storages/System/attachSystemTables.cpp b/src/Storages/System/attachSystemTables.cpp index 97eda1db3fa..53c572ebd46 100644 --- a/src/Storages/System/attachSystemTables.cpp +++ b/src/Storages/System/attachSystemTables.cpp @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -172,6 +173,7 @@ void attachSystemTablesServer(ContextPtr context, IDatabase & system_database, b attach(context, system_database, "schema_inference_cache", "Contains information about all cached file schemas."); attach(context, system_database, "dropped_tables", "Contains a list of tables which were dropped from Atomic databases but not completely removed yet."); attachNoDescription(context, system_database, "dropped_tables_parts", "Contains parts of system.dropped_tables tables "); + attachNoDescription(context, system_database, "dropped_tables_projection_parts", "Contains projection parts of system.dropped_tables tables "); attach(context, system_database, "scheduler", "Contains information and status for scheduling nodes residing on the local server."); attach(context, system_database, "dns_cache", "Contains information about cached DNS records."); #if defined(__ELF__) && !defined(OS_FREEBSD) diff --git a/tests/queries/0_stateless/01600_parts_states_metrics_long.sh b/tests/queries/0_stateless/01600_parts_states_metrics_long.sh index 0a9f94cc451..dfed2129054 100755 --- a/tests/queries/0_stateless/01600_parts_states_metrics_long.sh +++ b/tests/queries/0_stateless/01600_parts_states_metrics_long.sh @@ -28,6 +28,7 @@ verify() SELECT active FROM system.parts UNION ALL SELECT active FROM system.projection_parts UNION ALL SELECT 1 FROM system.dropped_tables_parts + UNION ALL SELECT active FROM system.dropped_tables_projection_parts ))" ) @@ -44,6 +45,7 @@ verify() SELECT sum(active), sum(NOT active) FROM system.parts; SELECT sum(active), sum(NOT active) FROM system.projection_parts; SELECT count() FROM system.dropped_tables_parts; + SELECT sum(active), sum(NOT active) FROM system.dropped_tables_projection_parts; " } diff --git a/tests/queries/0_stateless/02947_dropped_tables_projection_parts.reference b/tests/queries/0_stateless/02947_dropped_tables_projection_parts.reference new file mode 100644 index 00000000000..ffa38bafc61 --- /dev/null +++ b/tests/queries/0_stateless/02947_dropped_tables_projection_parts.reference @@ -0,0 +1,4 @@ +02947_table_1 all_1_1_0 +02947_table_2 all_1_1_0 +02947_table_1 maxdate +02947_table_2 maxdate diff --git a/tests/queries/0_stateless/02947_dropped_tables_projection_parts.sql b/tests/queries/0_stateless/02947_dropped_tables_projection_parts.sql new file mode 100644 index 00000000000..02558b07e16 --- /dev/null +++ b/tests/queries/0_stateless/02947_dropped_tables_projection_parts.sql @@ -0,0 +1,14 @@ +DROP TABLE IF EXISTS 02947_table_1; +DROP TABLE IF EXISTS 02947_table_2; + +CREATE TABLE 02947_table_1 (id Int32, PROJECTION maxdate(SELECT max(id))) Engine=MergeTree() ORDER BY id; +CREATE TABLE 02947_table_2 (id Int32, PROJECTION maxdate(SELECT max(id))) Engine=MergeTree() ORDER BY id; +INSERT INTO 02947_table_1 VALUES (1),(2); +INSERT INTO 02947_table_2 VALUES (3),(4); + +SELECT table, name FROM system.parts WHERE database = currentDatabase() AND startsWith(table, '02947_table_') ORDER BY 1, 2; + +SET database_atomic_wait_for_drop_and_detach_synchronously=0; +DROP TABLE 02947_table_1; +DROP TABLE 02947_table_2; +SELECT table, name FROM system.dropped_tables_projection_parts WHERE database = currentDatabase() AND startsWith(table, '02947_table_') ORDER BY 1, 2;