refactor format

This commit is contained in:
Amos Bird 2022-05-24 12:09:00 +08:00
parent 983e52cd3f
commit 76ddb39d02
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
2 changed files with 14 additions and 16 deletions

View File

@ -997,8 +997,8 @@ void ActionsDAG::addMaterializingOutputActions()
const ActionsDAG::Node & ActionsDAG::materializeNode(const Node & node) const ActionsDAG::Node & ActionsDAG::materializeNode(const Node & node)
{ {
FunctionOverloadResolverPtr func_builder_materialize = std::make_unique<FunctionToOverloadResolverAdaptor>( FunctionOverloadResolverPtr func_builder_materialize
std::make_shared<FunctionMaterialize>()); = std::make_unique<FunctionToOverloadResolverAdaptor>(std::make_shared<FunctionMaterialize>());
const auto & name = node.result_name; const auto & name = node.result_name;
const auto * func = &addFunction(func_builder_materialize, {&node}, {}); const auto * func = &addFunction(func_builder_materialize, {&node}, {});
@ -1102,7 +1102,8 @@ ActionsDAGPtr ActionsDAG::makeConvertingActions(
const auto * left_arg = dst_node; const auto * left_arg = dst_node;
FunctionCastBase::Diagnostic diagnostic = {dst_node->result_name, res_elem.name}; FunctionCastBase::Diagnostic diagnostic = {dst_node->result_name, res_elem.name};
FunctionOverloadResolverPtr func_builder_cast = CastInternalOverloadResolver<CastType::nonAccurate>::createImpl(std::move(diagnostic)); FunctionOverloadResolverPtr func_builder_cast
= CastInternalOverloadResolver<CastType::nonAccurate>::createImpl(std::move(diagnostic));
NodeRawConstPtrs children = { left_arg, right_arg }; NodeRawConstPtrs children = { left_arg, right_arg };
dst_node = &actions_dag->addFunction(func_builder_cast, std::move(children), {}); dst_node = &actions_dag->addFunction(func_builder_cast, std::move(children), {});
@ -1150,7 +1151,8 @@ ActionsDAGPtr ActionsDAG::makeConvertingActions(
ActionsDAGPtr ActionsDAG::makeAddingColumnActions(ColumnWithTypeAndName column) ActionsDAGPtr ActionsDAG::makeAddingColumnActions(ColumnWithTypeAndName column)
{ {
auto adding_column_action = std::make_shared<ActionsDAG>(); auto adding_column_action = std::make_shared<ActionsDAG>();
FunctionOverloadResolverPtr func_builder_materialize = std::make_unique<FunctionToOverloadResolverAdaptor>(std::make_shared<FunctionMaterialize>()); FunctionOverloadResolverPtr func_builder_materialize
= std::make_unique<FunctionToOverloadResolverAdaptor>(std::make_shared<FunctionMaterialize>());
auto column_name = column.name; auto column_name = column.name;
const auto * column_node = &adding_column_action->addColumn(std::move(column)); const auto * column_node = &adding_column_action->addColumn(std::move(column));
@ -1612,7 +1614,7 @@ ConjunctionNodes getConjunctionNodes(ActionsDAG::Node * predicate, std::unordere
std::stack<Frame> stack; std::stack<Frame> stack;
std::unordered_set<const ActionsDAG::Node *> visited_nodes; std::unordered_set<const ActionsDAG::Node *> visited_nodes;
stack.push(Frame{.node = predicate}); stack.push({.node = predicate});
visited_nodes.insert(predicate); visited_nodes.insert(predicate);
while (!stack.empty()) while (!stack.empty())
{ {
@ -1798,9 +1800,8 @@ ActionsDAGPtr ActionsDAG::cloneActionsForFilterPushDown(
{ {
Node * predicate = const_cast<Node *>(tryFindInIndex(filter_name)); Node * predicate = const_cast<Node *>(tryFindInIndex(filter_name));
if (!predicate) if (!predicate)
throw Exception(ErrorCodes::LOGICAL_ERROR, throw Exception(
"Index for ActionsDAG does not contain filter column name {}. DAG:\n{}", ErrorCodes::LOGICAL_ERROR, "Index for ActionsDAG does not contain filter column name {}. DAG:\n{}", filter_name, dumpDAG());
filter_name, dumpDAG());
/// If condition is constant let's do nothing. /// If condition is constant let's do nothing.
/// It means there is nothing to push down or optimization was already applied. /// It means there is nothing to push down or optimization was already applied.
@ -1870,8 +1871,6 @@ ActionsDAGPtr ActionsDAG::cloneActionsForFilterPushDown(
index_node = new_predicate; index_node = new_predicate;
} }
} }
removeUnusedActions(false);
} }
else else
{ {
@ -1926,10 +1925,9 @@ ActionsDAGPtr ActionsDAG::cloneActionsForFilterPushDown(
predicate->function_base = predicate->function_builder->build(arguments); predicate->function_base = predicate->function_builder->build(arguments);
predicate->function = predicate->function_base->prepare(arguments); predicate->function = predicate->function_base->prepare(arguments);
} }
removeUnusedActions(false);
} }
removeUnusedActions(false);
return actions; return actions;
} }

View File

@ -34,7 +34,7 @@ void optimizeTree(const QueryPlanOptimizationSettings & settings, QueryPlan::Nod
}; };
std::stack<Frame> stack; std::stack<Frame> stack;
stack.push(Frame{.node = &root}); stack.push({.node = &root});
size_t max_optimizations_to_apply = settings.max_optimizations_to_apply; size_t max_optimizations_to_apply = settings.max_optimizations_to_apply;
size_t total_applied_optimizations = 0; size_t total_applied_optimizations = 0;
@ -50,10 +50,10 @@ void optimizeTree(const QueryPlanOptimizationSettings & settings, QueryPlan::Nod
/// Traverse all children first. /// Traverse all children first.
if (frame.next_child < frame.node->children.size()) if (frame.next_child < frame.node->children.size())
{ {
stack.push(Frame stack.push(
{ {
.node = frame.node->children[frame.next_child], .node = frame.node->children[frame.next_child],
.depth_limit = frame.depth_limit ? (frame.depth_limit - 1) : 0, .depth_limit = frame.depth_limit ? (frame.depth_limit - 1) : 0,
}); });
++frame.next_child; ++frame.next_child;