提交 c8f655c1 编写于 作者: Z zhang2014

ISSUES-2259 fix the test after the merge master

上级 6613e567
......@@ -2,6 +2,7 @@
#include <Interpreters/InterpreterDropQuery.h>
#include <DataStreams/RemoteBlockInputStream.h>
#include <Interpreters/Cluster.h>
#include <ext/range.h>
namespace DB
{
......@@ -9,8 +10,9 @@ namespace DB
namespace ClusterProxy
{
TruncateStreamFactory::TruncateStreamFactory(ClusterPtr & cluster_, String & storage_path_) : cluster(cluster_), storage_path(storage_path_)
{}
TruncateStreamFactory::TruncateStreamFactory(ClusterPtr & cluster_) : cluster(cluster_)
{
}
void TruncateStreamFactory::createForShard(
const Cluster::ShardInfo & shard_info,
......@@ -18,9 +20,6 @@ void TruncateStreamFactory::createForShard(
const ThrottlerPtr & throttler, Context & context,
BlockInputStreams & res)
{
/// TODO remove temporary
// removeTemporaryDir(shard_info);
if (shard_info.isLocal())
{
InterpreterDropQuery drop_query{query_ast, context};
......@@ -48,6 +47,8 @@ void TruncateStreamFactory::createForShard(
if (shard_info.hasInternalReplication())
break;
continue;
}
throw Exception("Connection pool for replica " + replicas[replica_index].readableString() + " does not exist", ErrorCodes::LOGICAL_ERROR);
......@@ -56,30 +57,6 @@ void TruncateStreamFactory::createForShard(
}
}
void TruncateStreamFactory::removeTemporaryDir(const Cluster::ShardInfo & shard_info) const
{
if (!shard_info.hasInternalReplication())
{
Cluster::Addresses addresses = cluster->getShardsAddresses().at(shard_info.shard_num);
for (auto & address : addresses)
{
auto temporary_file = Poco::File(storage_path + "/" + address.toStringFull());
if (temporary_file.exists())
temporary_file.remove(true);
}
return;
}
if (!shard_info.dir_name_for_internal_replication.empty())
{
auto temporary_file = Poco::File(storage_path + "/" + shard_info.dir_name_for_internal_replication);
if (temporary_file.exists())
temporary_file.remove(true);
}
}
Cluster::Addresses TruncateStreamFactory::getShardReplicasAddresses(const Cluster::ShardInfo & info)
{
const auto addresses_with_failovers = cluster->getShardsAddresses();
......
......@@ -12,7 +12,7 @@ class TruncateStreamFactory final : public IStreamFactory
{
public:
TruncateStreamFactory(ClusterPtr & cluster, String & storage_path);
TruncateStreamFactory(ClusterPtr & cluster);
void createForShard(
const Cluster::ShardInfo & shard_info,
......@@ -20,11 +20,8 @@ public:
const ThrottlerPtr & throttler, Context & context,
BlockInputStreams & res) override;
void removeTemporaryDir(const Cluster::ShardInfo &shard_info) const;
private:
ClusterPtr cluster;
String & storage_path;
ClusterPtr & cluster;
Cluster::Addresses getShardReplicasAddresses(const Cluster::ShardInfo &info);
};
......
......@@ -8,8 +8,6 @@
#include <Storages/IStorage.h>
#include <Common/escapeForFileName.h>
#include <Common/typeid_cast.h>
#include <Functions/GatherUtils/Algorithms.h>
#include <AggregateFunctions/AggregateFunctionSequenceMatch.h>
namespace DB
......
......@@ -3,11 +3,14 @@
#include <Parsers/IAST.h>
#include <Parsers/ASTQueryWithOutput.h>
#include <Parsers/ASTQueryWithOnCluster.h>
#include <AggregateFunctions/AggregateFunctionSequenceMatch.h>
namespace DB
{
namespace ErrorCodes
{
extern const int SYNTAX_ERROR;
}
/** DROP query
*/
......
......@@ -10,6 +10,11 @@
namespace DB
{
namespace ErrorCodes
{
extern const int SYNTAX_ERROR;
extern const int LOGICAL_ERROR;
}
bool ParserDropQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
......
......@@ -1580,7 +1580,6 @@ void MergeTreeData::renameAndDetachPart(const DataPartPtr & part_to_detach, cons
part->renameAddPrefix(move_to_detached, prefix);
data_parts_indexes.erase(it_part);
std::cout << "MergeTreeData::renameAndDetachPart \n";
if (restore_covered && part->info.level == 0)
{
LOG_WARNING(log, "Will not recover parts covered by zero-level part " << part->name);
......
......@@ -317,8 +317,7 @@ void StorageDistributed::truncate(const ASTPtr & query)
}
}
String storage_path = getDataPath();
ClusterProxy::TruncateStreamFactory truncate_stream_factory(cluster, storage_path);
ClusterProxy::TruncateStreamFactory truncate_stream_factory(cluster);
ClusterProxy::executeQuery(truncate_stream_factory, cluster, ast_drop_query, context, context.getSettingsRef());
}
......
......@@ -40,7 +40,7 @@ public:
void drop() override;
virtual void truncate(const ASTPtr & query) override;
void truncate(const ASTPtr & query) override;
void rename(const String & /*new_path_to_db*/, const String & /*new_database_name*/, const String & new_table_name) override { table_name = new_table_name; }
......
......@@ -120,8 +120,12 @@ size_t StorageSet::getSize() const { return set->getTotalRowCount(); }
void StorageSet::truncate(const ASTPtr & /*query*/)
{
Block header = getSampleBlock();
header = header.sortColumns();
increment = 0;
set = std::make_shared<Set>(SizeLimits());
set->setHeader(header);
static const auto file_suffix = ".bin";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册