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());
auto partition_commands_pipes = table->alterPartition(query_ptr, metadata_snapshot, partition_commands, context);
if (!partition_commands_pipes.empty())
{
QueryPipeline pipeline;
pipeline.init(std::move(partition_commands_pipes));
res.pipeline = std::move(pipeline);
}
res.pipeline.init(std::move(partition_commands_pipes));
}
if (!live_view_commands.empty())

View File

@ -5,6 +5,9 @@
#include <Parsers/ASTIdentifier.h>
#include <Core/ColumnWithTypeAndName.h>
#include <DataTypes/DataTypeString.h>
#include <Processors/Chunk.h>
#include <Processors/Pipe.h>
#include <Processors/Sources/SourceFromSingleChunk.h>
namespace DB
@ -132,7 +135,7 @@ std::string PartitionCommand::typeToString() const
__builtin_unreachable();
}
std::shared_ptr<SourceFromSingleChunk> convertCommandsResultToSource(const PartitionCommandsResultInfo & commands_result)
Pipes convertCommandsResultToSource(const PartitionCommandsResultInfo & commands_result)
{
Block header {
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());
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 <Parsers/IAST.h>
#include <Storages/IStorage_fwd.h>
#include <Processors/Sources/SourceFromSingleChunk.h>
#include <optional>
#include <vector>
@ -15,6 +14,9 @@ namespace DB
class ASTAlterCommand;
class Pipe;
using Pipes = std::vector<Pipe>;
struct PartitionCommand
{
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
/// results. For example, if all commands were FREEZE commands, than
/// 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)
{
auto source = convertCommandsResultToSource(result);
Pipes pipes;
pipes.emplace_back(Pipe(source));
return pipes;
}
return convertCommandsResultToSource(result);
return { };
}

View File

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