diff --git a/src/DataStreams/PushingToViewsBlockOutputStream.cpp b/src/DataStreams/PushingToViewsBlockOutputStream.cpp index b19b07a82bb..726d54558c2 100644 --- a/src/DataStreams/PushingToViewsBlockOutputStream.cpp +++ b/src/DataStreams/PushingToViewsBlockOutputStream.cpp @@ -404,6 +404,11 @@ Chain buildPushingToViewsDrain( InterpreterInsertQuery interpreter(nullptr, insert_context, false, false, false); out = interpreter.buildChain(inner_table, inner_metadata_snapshot, insert_columns, view_runtime_data); out.addStorageHolder(inner_table); + if (const auto * mv = dynamic_cast(inner_table.get())) + { + if (auto inner_mv_table = mv->tryGetTargetTable()) + out.addStorageHolder(inner_mv_table); + } } else if (auto * live_view = dynamic_cast(dependent_table.get())) {