Remove isReady from FutureSet iface.

This commit is contained in:
Nikolai Kochetov 2023-06-19 12:56:24 +00:00
parent f3398f9908
commit 8e7d06e0a4
8 changed files with 19 additions and 31 deletions

View File

@ -123,14 +123,10 @@ public:
}
auto future_set = column_set->getData();
if (!future_set || !future_set->isReady())
auto set = future_set ? future_set->get() : nullptr;
if (!future_set || !set)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Not-ready Set passed as the second argument for function '{}'", getName());
// if (auto * for_tuple = typeid_cast<FutureSetFromTuple *>(future_set.get()))
// if (!for_tuple->isReady())
// for_tuple->buildForTuple(size_limits, transform_null_in);
auto set = future_set->get();
auto set_types = set->getDataTypes();
if (tuple && set_types.size() != 1 && set_types.size() == tuple->tupleSize())

View File

@ -936,15 +936,12 @@ bool ExpressionActions::checkColumnIsAlwaysFalse(const String & column_name) con
for (const auto & action : actions)
{
if (action.node->type == ActionsDAG::ActionType::COLUMN && action.node->result_name == set_to_check)
{
// Constant ColumnSet cannot be empty, so we only need to check non-constant ones.
if (const auto * column_set = checkAndGetColumn<const ColumnSet>(action.node->column.get()))
{
auto set = column_set->getData();
if (set && set->isReady() && set->get()->getTotalRowCount() == 0)
return true;
}
}
if (auto future_set = column_set->getData())
if (auto set = future_set->get())
if (set->getTotalRowCount() == 0)
return true;
}
}

View File

@ -30,9 +30,7 @@ class FutureSetFromTuple final : public FutureSet
public:
FutureSetFromTuple(Block block, const Settings & settings);
bool isReady() const override { return true; }
SetPtr get() const override { return set; }
SetPtr buildOrderedSetInplace(const ContextPtr & context) override;
DataTypes getTypes() const override { return set->getElementsTypes(); }
@ -44,7 +42,6 @@ private:
FutureSetFromStorage::FutureSetFromStorage(SetPtr set_) : set(std::move(set_)) {}
bool FutureSetFromStorage::isReady() const { return set != nullptr; }
SetPtr FutureSetFromStorage::get() const { return set; }
DataTypes FutureSetFromStorage::getTypes() const { return set->getElementsTypes(); }
@ -297,7 +294,13 @@ SetPtr FutureSetFromSubquery::buildOrderedSetInplace(const ContextPtr & context)
return subquery.set;
}
bool FutureSetFromSubquery::isReady() const { return subquery.set != nullptr && subquery.set->isCreated(); }
SetPtr FutureSetFromSubquery::get() const
{
if (subquery.set != nullptr && subquery.set->isCreated())
return subquery.set;
return nullptr;
}
std::unique_ptr<QueryPlan> FutureSetFromSubquery::build(const ContextPtr & context)
{

View File

@ -34,9 +34,7 @@ class FutureSet
public:
virtual ~FutureSet() = default;
virtual bool isReady() const = 0;
virtual SetPtr get() const = 0;
virtual SetPtr buildOrderedSetInplace(const ContextPtr & context) = 0;
virtual DataTypes getTypes() const = 0;
@ -50,7 +48,6 @@ class FutureSetFromStorage : public FutureSet
public:
FutureSetFromStorage(SetPtr set_);
bool isReady() const override;
SetPtr get() const override;
SetPtr buildOrderedSetInplace(const ContextPtr &) override;
DataTypes getTypes() const override;
@ -91,8 +88,7 @@ class FutureSetFromSubquery : public FutureSet, public std::enable_shared_from_t
public:
FutureSetFromSubquery(SubqueryForSet subquery_, FutureSetPtr external_table_set_, bool transform_null_in_);
bool isReady() const override;
SetPtr get() const override { return subquery.set; }
SetPtr get() const override;
SetPtr buildOrderedSetInplace(const ContextPtr & context) override;

View File

@ -664,7 +664,7 @@ PlannerActionsVisitorImpl::NodeNameAndNodeMinLevel PlannerActionsVisitorImpl::ma
column.name = planner_context->createSetKey(in_second_argument);
column.type = std::make_shared<DataTypeSet>();
bool set_is_created = set->isReady();
bool set_is_created = set->get() != nullptr;
auto column_set = ColumnSet::create(1, std::move(set));
if (set_is_created)

View File

@ -137,7 +137,7 @@ void addCreatingSetsStep(QueryPlan & query_plan, PreparedSets::SubqueriesForSets
for (auto & [description, future_set] : subqueries_for_sets)
{
if (future_set->isReady())
if (future_set->get())
continue;
auto plan = future_set->build(context);
@ -172,7 +172,7 @@ std::vector<std::unique_ptr<QueryPlan>> DelayedCreatingSetsStep::makePlansForSet
for (auto & [description, future_set] : step.subqueries_for_sets)
{
if (future_set->isReady())
if (future_set->get())
continue;
auto plan = future_set->build(step.context);

View File

@ -384,11 +384,7 @@ FutureSetPtr RPNBuilderTreeNode::tryGetPreparedSet(
if (node_without_alias->column)
{
auto future_set = tryGetSetFromDAGNode(node_without_alias);
if (const auto * from_subquery = typeid_cast<const FutureSetFromSubquery *>(future_set.get()))
return future_set;
auto set_types = future_set->getTypes();
if (types_match(set_types))
if (types_match(future_set->getTypes()))
return future_set;
}
}

View File

@ -222,7 +222,7 @@ void filterBlockWithQuery(const ASTPtr & query, Block & block, ContextPtr contex
if (column_set)
{
auto future_set = column_set->getData();
if (!future_set->isReady())
if (!future_set->get())
{
if (auto * set_from_subquery = typeid_cast<FutureSetFromSubquery *>(future_set.get()))
{