Review fixe

This commit is contained in:
alesapin 2020-07-29 11:32:52 +03:00
parent b02951fd3a
commit 7fc1e45c3b
5 changed files with 15 additions and 21 deletions

View File

@ -89,11 +89,7 @@ BlockIO InterpreterAlterQuery::execute()
table->checkAlterPartitionIsPossible(partition_commands, metadata_snapshot, context.getSettingsRef()); table->checkAlterPartitionIsPossible(partition_commands, metadata_snapshot, context.getSettingsRef());
auto partition_commands_pipes = table->alterPartition(query_ptr, metadata_snapshot, partition_commands, context); auto partition_commands_pipes = table->alterPartition(query_ptr, metadata_snapshot, partition_commands, context);
if (!partition_commands_pipes.empty()) if (!partition_commands_pipes.empty())
{ res.pipeline.init(std::move(partition_commands_pipes));
QueryPipeline pipeline;
pipeline.init(std::move(partition_commands_pipes));
res.pipeline = std::move(pipeline);
}
} }
if (!live_view_commands.empty()) if (!live_view_commands.empty())

View File

@ -5,6 +5,9 @@
#include <Parsers/ASTIdentifier.h> #include <Parsers/ASTIdentifier.h>
#include <Core/ColumnWithTypeAndName.h> #include <Core/ColumnWithTypeAndName.h>
#include <DataTypes/DataTypeString.h> #include <DataTypes/DataTypeString.h>
#include <Processors/Chunk.h>
#include <Processors/Pipe.h>
#include <Processors/Sources/SourceFromSingleChunk.h>
namespace DB namespace DB
@ -132,7 +135,7 @@ std::string PartitionCommand::typeToString() const
__builtin_unreachable(); __builtin_unreachable();
} }
std::shared_ptr<SourceFromSingleChunk> convertCommandsResultToSource(const PartitionCommandsResultInfo & commands_result) Pipes convertCommandsResultToSource(const PartitionCommandsResultInfo & commands_result)
{ {
Block header { Block header {
ColumnWithTypeAndName(std::make_shared<DataTypeString>(), "command_type"), ColumnWithTypeAndName(std::make_shared<DataTypeString>(), "command_type"),
@ -178,7 +181,10 @@ std::shared_ptr<SourceFromSingleChunk> convertCommandsResultToSource(const Parti
Chunk chunk(std::move(res_columns), commands_result.size()); Chunk chunk(std::move(res_columns), commands_result.size());
return std::make_shared<SourceFromSingleChunk>(std::move(header), std::move(chunk)); Pipe pipe(std::make_shared<SourceFromSingleChunk>(std::move(header), std::move(chunk)));
Pipes result;
result.emplace_back(std::move(pipe));
return result;
} }
} }

View File

@ -4,7 +4,6 @@
#include <Core/Types.h> #include <Core/Types.h>
#include <Parsers/IAST.h> #include <Parsers/IAST.h>
#include <Storages/IStorage_fwd.h> #include <Storages/IStorage_fwd.h>
#include <Processors/Sources/SourceFromSingleChunk.h>
#include <optional> #include <optional>
#include <vector> #include <vector>
@ -15,6 +14,9 @@ namespace DB
class ASTAlterCommand; class ASTAlterCommand;
class Pipe;
using Pipes = std::vector<Pipe>;
struct PartitionCommand struct PartitionCommand
{ {
enum Type enum Type
@ -100,6 +102,6 @@ using PartitionCommandsResultInfo = std::vector<PartitionCommandResultInfo>;
/// used to print info to the user. Tries to create narrowest table for given /// used to print info to the user. Tries to create narrowest table for given
/// results. For example, if all commands were FREEZE commands, than /// results. For example, if all commands were FREEZE commands, than
/// old_part_name column will be absent. /// old_part_name column will be absent.
std::shared_ptr<SourceFromSingleChunk> convertCommandsResultToSource(const PartitionCommandsResultInfo & commands_result); Pipes convertCommandsResultToSource(const PartitionCommandsResultInfo & commands_result);
} }

View File

@ -1088,12 +1088,7 @@ Pipes StorageMergeTree::alterPartition(
} }
if (query_context.getSettingsRef().alter_partition_verbose_result) if (query_context.getSettingsRef().alter_partition_verbose_result)
{ return convertCommandsResultToSource(result);
auto source = convertCommandsResultToSource(result);
Pipes pipes;
pipes.emplace_back(Pipe(source));
return pipes;
}
return { }; return { };
} }

View File

@ -3930,12 +3930,7 @@ Pipes StorageReplicatedMergeTree::alterPartition(
} }
if (query_context.getSettingsRef().alter_partition_verbose_result) if (query_context.getSettingsRef().alter_partition_verbose_result)
{ return convertCommandsResultToSource(result);
auto source = convertCommandsResultToSource(result);
Pipes pipes;
pipes.emplace_back(Pipe(source));
return pipes;
}
return {}; return {};
} }