This commit is contained in:
Alexander Tokmakov 2021-07-01 19:43:59 +03:00
parent d9a77e3a1a
commit 1b2416007e
2 changed files with 30 additions and 22 deletions

View File

@ -77,6 +77,7 @@ namespace ErrorCodes
{ {
extern const int INTO_OUTFILE_NOT_ALLOWED; extern const int INTO_OUTFILE_NOT_ALLOWED;
extern const int QUERY_WAS_CANCELLED; extern const int QUERY_WAS_CANCELLED;
extern const int LOGICAL_ERROR;
} }
@ -1059,12 +1060,6 @@ void executeQuery(
copyData(*streams.in, *out, [](){ return false; }, [&out](const Block &) { out->flush(); }); copyData(*streams.in, *out, [](){ return false; }, [&out](const Block &) { out->flush(); });
} }
else if (pipeline.initialized()) else if (pipeline.initialized())
{
if (pipeline.isCompleted())
{
pipeline.setProgressCallback(context->getProgressCallback());
}
else
{ {
const ASTQueryWithOutput * ast_query_with_output = dynamic_cast<const ASTQueryWithOutput *>(ast.get()); const ASTQueryWithOutput * ast_query_with_output = dynamic_cast<const ASTQueryWithOutput *>(ast.get());
@ -1084,6 +1079,8 @@ void executeQuery(
? getIdentifierName(ast_query_with_output->format) ? getIdentifierName(ast_query_with_output->format)
: context->getDefaultFormat(); : context->getDefaultFormat();
if (!pipeline.isCompleted())
{
pipeline.addSimpleTransform([](const Block & header) pipeline.addSimpleTransform([](const Block & header)
{ {
return std::make_shared<MaterializingTransform>(header); return std::make_shared<MaterializingTransform>(header);
@ -1109,6 +1106,10 @@ void executeQuery(
pipeline.setOutputFormat(std::move(out)); pipeline.setOutputFormat(std::move(out));
} }
else
{
pipeline.setProgressCallback(context->getProgressCallback());
}
{ {
auto executor = pipeline.execute(); auto executor = pipeline.execute();

View File

@ -1138,9 +1138,16 @@ ActionLock StorageDistributed::getActionLock(StorageActionBlockType type)
} }
void StorageDistributed::flush() void StorageDistributed::flush()
{
try
{ {
flushClusterNodesAllData(getContext()); flushClusterNodesAllData(getContext());
} }
catch (...)
{
tryLogCurrentException(log, "Cannot flush");
}
}
void StorageDistributed::flushClusterNodesAllData(ContextPtr local_context) void StorageDistributed::flushClusterNodesAllData(ContextPtr local_context)
{ {