mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Fix more tests.
This commit is contained in:
parent
518ba6cbf6
commit
5a1f819e7b
@ -455,7 +455,7 @@ FutureSetPtr makeExplicitSet(
|
||||
// std::cerr << "========== " << set_element_types[0]->getName() << std::endl;
|
||||
|
||||
auto set_key = right_arg->getTreeHash();
|
||||
if (auto set = prepared_sets.find(set_key, set_element_types))
|
||||
if (auto set = prepared_sets.findTuple(set_key, set_element_types))
|
||||
return set; /// Already prepared.
|
||||
|
||||
Block block;
|
||||
|
@ -178,21 +178,10 @@ static FutureSetPtr findSet(const std::vector<std::shared_ptr<FutureSet>> & sets
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FutureSetPtr PreparedSets::addFromStorage(const Hash & key, SetPtr set_)
|
||||
{
|
||||
auto from_storage = std::make_shared<FutureSetFromStorage>(std::move(set_));
|
||||
auto & sets_by_hash = sets[key];
|
||||
|
||||
if (!tryInsertSet(sets_by_hash, from_storage))
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Duplicate set: {}", toString(key, from_storage->getTypes()));
|
||||
|
||||
return from_storage;
|
||||
}
|
||||
|
||||
FutureSetPtr PreparedSets::addFromTuple(const Hash & key, Block block, const Settings & settings)
|
||||
{
|
||||
auto from_tuple = std::make_shared<FutureSetFromTuple>(std::move(block), settings);
|
||||
auto & sets_by_hash = sets[key];
|
||||
auto & sets_by_hash = sets_from_tuple[key];
|
||||
|
||||
if (!tryInsertSet(sets_by_hash, from_tuple))
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Duplicate set: {}", toString(key, from_tuple->getTypes()));
|
||||
@ -200,6 +189,17 @@ FutureSetPtr PreparedSets::addFromTuple(const Hash & key, Block block, const Set
|
||||
return from_tuple;
|
||||
}
|
||||
|
||||
FutureSetPtr PreparedSets::addFromStorage(const Hash & key, SetPtr set_)
|
||||
{
|
||||
auto from_storage = std::make_shared<FutureSetFromStorage>(std::move(set_));
|
||||
auto [it, inserted] = sets_from_storage.emplace(key, from_storage);
|
||||
|
||||
if (!inserted)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Duplicate set: {}", toString(key, {}));
|
||||
|
||||
return from_storage;
|
||||
}
|
||||
|
||||
FutureSetPtr PreparedSets::addFromSubquery(const Hash & key, SubqueryForSet subquery, const Settings & settings, FutureSetPtr external_table_set)
|
||||
{
|
||||
auto from_subquery = std::make_shared<FutureSetFromSubquery>(std::move(subquery), std::move(external_table_set), settings);
|
||||
@ -215,10 +215,10 @@ FutureSetPtr PreparedSets::addFromSubquery(const Hash & key, SubqueryForSet subq
|
||||
return from_subquery;
|
||||
}
|
||||
|
||||
FutureSetPtr PreparedSets::find(const Hash & key, const DataTypes & types) const
|
||||
FutureSetPtr PreparedSets::findTuple(const Hash & key, const DataTypes & types) const
|
||||
{
|
||||
auto it = sets.find(key);
|
||||
if (it == sets.end())
|
||||
auto it = sets_from_tuple.find(key);
|
||||
if (it == sets_from_tuple.end())
|
||||
return nullptr;
|
||||
|
||||
return findSet(it->second, types);
|
||||
@ -233,6 +233,15 @@ std::shared_ptr<FutureSetFromSubquery> PreparedSets::findSubquery(const Hash & k
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<FutureSetFromStorage> PreparedSets::findStorage(const Hash & key) const
|
||||
{
|
||||
auto it = sets_from_storage.find(key);
|
||||
if (it == sets_from_storage.end())
|
||||
return nullptr;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
// FutureSetPtr PreparedSets::getFuture(const PreparedSetKey & key) const
|
||||
// {
|
||||
// auto it = sets.find(key);
|
||||
|
@ -148,14 +148,16 @@ public:
|
||||
// std::shared_ptr<FutureSetFromSubquery> set;
|
||||
// };
|
||||
|
||||
using Sets = std::unordered_map<Hash, std::vector<std::shared_ptr<FutureSet>>, Hashing>;
|
||||
using SetsFromTuple = std::unordered_map<Hash, std::vector<std::shared_ptr<FutureSet>>, Hashing>;
|
||||
using SetsFromStorage = std::unordered_map<Hash, std::shared_ptr<FutureSetFromStorage>, Hashing>;
|
||||
using SetsFromSubqueries = std::unordered_map<Hash, std::shared_ptr<FutureSetFromSubquery>, Hashing>;
|
||||
|
||||
FutureSetPtr addFromStorage(const Hash & key, SetPtr set_);
|
||||
FutureSetPtr addFromTuple(const Hash & key, Block block, const Settings & settings);
|
||||
FutureSetPtr addFromSubquery(const Hash & key, SubqueryForSet subquery, const Settings & settings, FutureSetPtr external_table_set);
|
||||
|
||||
FutureSetPtr find(const Hash & key, const DataTypes & types) const;
|
||||
FutureSetPtr findTuple(const Hash & key, const DataTypes & types) const;
|
||||
std::shared_ptr<FutureSetFromStorage> findStorage(const Hash & key) const;
|
||||
std::shared_ptr<FutureSetFromSubquery> findSubquery(const Hash & key) const;
|
||||
|
||||
//FutureSetPtr getFuture(const PreparedSetKey & key) const;
|
||||
@ -165,13 +167,15 @@ public:
|
||||
/// SetPtr would still be available for consumers of PreparedSets.
|
||||
std::vector<std::shared_ptr<FutureSetFromSubquery>> detachSubqueries();
|
||||
|
||||
const Sets & getNormalSets() const { return sets; }
|
||||
const SetsFromTuple & getSetsFromTuple() const { return sets_from_tuple; }
|
||||
const SetsFromStorage & getSetsFromStorage() const { return sets_from_storage; }
|
||||
const SetsFromSubqueries & getSetsFromSubquery() const { return sets_from_subqueries; }
|
||||
|
||||
static String toString(const Hash & key, const DataTypes & types);
|
||||
|
||||
private:
|
||||
Sets sets;
|
||||
SetsFromTuple sets_from_tuple;
|
||||
SetsFromStorage sets_from_storage;
|
||||
SetsFromSubqueries sets_from_subqueries;
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
// element_type = low_cardinality_type->getDictionaryType();
|
||||
|
||||
auto set_key = in_second_argument->getTreeHash();
|
||||
if (sets.find(set_key, set_element_types))
|
||||
if (sets.findTuple(set_key, set_element_types))
|
||||
return;
|
||||
|
||||
sets.addFromTuple(set_key, std::move(set), settings);
|
||||
|
@ -654,10 +654,14 @@ PlannerActionsVisitorImpl::NodeNameAndNodeMinLevel PlannerActionsVisitorImpl::ma
|
||||
// element_type = low_cardinality_type->getDictionaryType();
|
||||
|
||||
set_element_types = Set::getElementTypes(std::move(set_element_types), planner_context->getQueryContext()->getSettingsRef().transform_null_in);
|
||||
set = planner_context->getPreparedSets().find(set_key, set_element_types);
|
||||
set = planner_context->getPreparedSets().findTuple(set_key, set_element_types);
|
||||
}
|
||||
else
|
||||
{
|
||||
set = planner_context->getPreparedSets().findSubquery(set_key);
|
||||
if (!set)
|
||||
set = planner_context->getPreparedSets().findStorage(set_key);
|
||||
}
|
||||
|
||||
if (!set)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
|
@ -72,7 +72,7 @@ bool traverseASTFilter(
|
||||
if ((value->as<ASTSubquery>() || value->as<ASTIdentifier>()))
|
||||
future_set = prepared_sets->findSubquery(set_key);
|
||||
else
|
||||
future_set = prepared_sets->find(set_key, {primary_key_type});
|
||||
future_set = prepared_sets->findTuple(set_key, {primary_key_type});
|
||||
|
||||
if (!future_set)
|
||||
return false;
|
||||
|
@ -300,7 +300,7 @@ FutureSetPtr RPNBuilderTreeNode::tryGetPreparedSet() const
|
||||
if (ast_node && prepared_sets)
|
||||
{
|
||||
auto key = ast_node->getTreeHash();
|
||||
const auto & sets = prepared_sets->getNormalSets();
|
||||
const auto & sets = prepared_sets->getSetsFromTuple();
|
||||
auto it = sets.find(key);
|
||||
if (it != sets.end() && !it->second.empty())
|
||||
return it->second.at(0);
|
||||
@ -325,7 +325,7 @@ FutureSetPtr RPNBuilderTreeNode::tryGetPreparedSet(const DataTypes & data_types)
|
||||
if (ast_node->as<ASTSubquery>() || ast_node->as<ASTTableIdentifier>())
|
||||
return prepared_sets->findSubquery(ast_node->getTreeHash());
|
||||
|
||||
return prepared_sets->find(ast_node->getTreeHash(), data_types);
|
||||
return prepared_sets->findTuple(ast_node->getTreeHash(), data_types);
|
||||
}
|
||||
else if (dag_node)
|
||||
{
|
||||
@ -371,7 +371,7 @@ FutureSetPtr RPNBuilderTreeNode::tryGetPreparedSet(
|
||||
return prepared_sets->findSubquery(ast_node->getTreeHash());
|
||||
|
||||
auto tree_hash = ast_node->getTreeHash();
|
||||
const auto & sets = prepared_sets->getNormalSets();
|
||||
const auto & sets = prepared_sets->getSetsFromTuple();
|
||||
auto it = sets.find(tree_hash);
|
||||
if (it == sets.end())
|
||||
return nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user