diff --git a/dbms/src/Storages/StorageMaterializedView.cpp b/dbms/src/Storages/StorageMaterializedView.cpp index 1929ffc815d..4668eb6c25e 100644 --- a/dbms/src/Storages/StorageMaterializedView.cpp +++ b/dbms/src/Storages/StorageMaterializedView.cpp @@ -175,6 +175,14 @@ bool StorageMaterializedView::optimize(const ASTPtr & query, const ASTPtr & part return getTargetTable()->optimize(query, partition, final, deduplicate, context); } +void StorageMaterializedView::shutdown() +{ + /// Make sure the dependency is removed after DETACH TABLE + global_context.removeDependency( + DatabaseAndTableName(select_database_name, select_table_name), + DatabaseAndTableName(database_name, table_name)); +} + StoragePtr StorageMaterializedView::getTargetTable() const { return global_context.getTable(target_database_name, target_table_name); diff --git a/dbms/src/Storages/StorageMaterializedView.h b/dbms/src/Storages/StorageMaterializedView.h index bd4870a2d35..9cf5331207d 100644 --- a/dbms/src/Storages/StorageMaterializedView.h +++ b/dbms/src/Storages/StorageMaterializedView.h @@ -33,6 +33,7 @@ public: BlockOutputStreamPtr write(const ASTPtr & query, const Settings & settings) override; void drop() override; bool optimize(const ASTPtr & query, const ASTPtr & partition, bool final, bool deduplicate, const Context & context) override; + void shutdown() override; BlockInputStreams read( const Names & column_names,