diff --git a/src/DataStreams/PushingToViewsBlockOutputStream.cpp b/src/DataStreams/PushingToViewsBlockOutputStream.cpp index 3d843f10e9a..f6fd978fde2 100644 --- a/src/DataStreams/PushingToViewsBlockOutputStream.cpp +++ b/src/DataStreams/PushingToViewsBlockOutputStream.cpp @@ -92,10 +92,6 @@ PushingToViewsBlockOutputStream::PushingToViewsBlockOutputStream( views.emplace_back(ViewInfo{std::move(query), database_table, std::move(out)}); } - /// Remove calculated scalar subquery results, because they can be calculated for real, not substituted tables. - if (views_context && views_context->hasQueryContext()) - views_context->getQueryContext().dropScalars(); - /// Do not push to destination table if the flag is set if (!no_destination) { diff --git a/src/Interpreters/InterpreterSelectQuery.cpp b/src/Interpreters/InterpreterSelectQuery.cpp index a189ca38753..e3a0857e17a 100644 --- a/src/Interpreters/InterpreterSelectQuery.cpp +++ b/src/Interpreters/InterpreterSelectQuery.cpp @@ -314,7 +314,7 @@ InterpreterSelectQuery::InterpreterSelectQuery( options, joined_tables.tablesWithColumns(), required_result_column_names, table_join); /// Save scalar sub queries's results in the query context - if (context->hasQueryContext()) + if (!options.only_analyze && context->hasQueryContext()) for (const auto & it : syntax_analyzer_result->getScalars()) context->getQueryContext().addScalar(it.first, it.second);