mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Renames.
This commit is contained in:
parent
aeee0b2c18
commit
153268a29f
@ -507,13 +507,12 @@ struct ActionDAGNodes
|
||||
ActionsDAG::NodeRawConstPtrs nodes;
|
||||
};
|
||||
|
||||
struct ActionsAndFlags
|
||||
struct ActionsAndProjectInputsFlag
|
||||
{
|
||||
ActionsDAG actions;
|
||||
ActionsDAG dag;
|
||||
bool project_input = false;
|
||||
bool projected_output = false;
|
||||
};
|
||||
|
||||
using ActionsAndFlagsPtr = std::shared_ptr<ActionsAndFlags>;
|
||||
using ActionsAndProjectInputsFlagPtr = std::shared_ptr<ActionsAndProjectInputsFlag>;
|
||||
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ void ExpressionActionsChain::addStep(NameSet non_constant_inputs)
|
||||
if (column.column && isColumnConst(*column.column) && non_constant_inputs.contains(column.name))
|
||||
column.column = nullptr;
|
||||
|
||||
steps.push_back(std::make_unique<ExpressionActionsStep>(std::make_shared<ActionsAndFlags>(ActionsDAG(columns), false, false)));
|
||||
steps.push_back(std::make_unique<ExpressionActionsStep>(std::make_shared<ActionsAndProjectInputsFlag>(ActionsDAG(columns), false)));
|
||||
}
|
||||
|
||||
void ExpressionActionsChain::finalize()
|
||||
@ -1129,12 +1129,12 @@ void ExpressionActionsChain::JoinStep::finalize(const NameSet & required_output_
|
||||
std::swap(result_columns, new_result_columns);
|
||||
}
|
||||
|
||||
ActionsAndFlagsPtr & ExpressionActionsChain::Step::actions()
|
||||
ActionsAndProjectInputsFlagPtr & ExpressionActionsChain::Step::actions()
|
||||
{
|
||||
return typeid_cast<ExpressionActionsStep &>(*this).actions_and_flags;
|
||||
}
|
||||
|
||||
const ActionsAndFlagsPtr & ExpressionActionsChain::Step::actions() const
|
||||
const ActionsAndProjectInputsFlagPtr & ExpressionActionsChain::Step::actions() const
|
||||
{
|
||||
return typeid_cast<const ExpressionActionsStep &>(*this).actions_and_flags;
|
||||
}
|
||||
|
@ -179,15 +179,16 @@ struct ExpressionActionsChain : WithContext
|
||||
virtual std::string dump() const = 0;
|
||||
|
||||
/// Only for ExpressionActionsStep
|
||||
ActionsAndFlagsPtr & actions();
|
||||
const ActionsAndFlagsPtr & actions() const;
|
||||
ActionsAndProjectInputsFlagPtr & actions();
|
||||
const ActionsAndProjectInputsFlagPtr & actions() const;
|
||||
};
|
||||
|
||||
struct ExpressionActionsStep : public Step
|
||||
{
|
||||
ActionsAndFlagsPtr actions_and_flags;
|
||||
ActionsAndProjectInputsFlagPtr actions_and_flags;
|
||||
bool is_final_projection = false;
|
||||
|
||||
explicit ExpressionActionsStep(ActionsAndFlagsPtr actiactions_and_flags_, Names required_output_ = Names())
|
||||
explicit ExpressionActionsStep(ActionsAndProjectInputsFlagPtr actiactions_and_flags_, Names required_output_ = Names())
|
||||
: Step(std::move(required_output_))
|
||||
, actions_and_flags(std::move(actiactions_and_flags_))
|
||||
{
|
||||
@ -195,18 +196,18 @@ struct ExpressionActionsChain : WithContext
|
||||
|
||||
NamesAndTypesList getRequiredColumns() const override
|
||||
{
|
||||
return actions_and_flags->actions.getRequiredColumns();
|
||||
return actions_and_flags->dag.getRequiredColumns();
|
||||
}
|
||||
|
||||
ColumnsWithTypeAndName getResultColumns() const override
|
||||
{
|
||||
return actions_and_flags->actions.getResultColumns();
|
||||
return actions_and_flags->dag.getResultColumns();
|
||||
}
|
||||
|
||||
void finalize(const NameSet & required_output_) override
|
||||
{
|
||||
if (!actions_and_flags->projected_output)
|
||||
actions_and_flags->actions.removeUnusedActions(required_output_);
|
||||
if (!is_final_projection)
|
||||
actions_and_flags->dag.removeUnusedActions(required_output_);
|
||||
}
|
||||
|
||||
void prependProjectInput() override
|
||||
@ -216,7 +217,7 @@ struct ExpressionActionsChain : WithContext
|
||||
|
||||
std::string dump() const override
|
||||
{
|
||||
return actions_and_flags->actions.dumpDAG();
|
||||
return actions_and_flags->dag.dumpDAG();
|
||||
}
|
||||
};
|
||||
|
||||
@ -265,7 +266,7 @@ struct ExpressionActionsChain : WithContext
|
||||
steps.clear();
|
||||
}
|
||||
|
||||
ActionsAndFlagsPtr getLastActions(bool allow_empty = false)
|
||||
ExpressionActionsStep * getLastExpressionStep(bool allow_empty = false)
|
||||
{
|
||||
if (steps.empty())
|
||||
{
|
||||
@ -274,7 +275,15 @@ struct ExpressionActionsChain : WithContext
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Empty ExpressionActionsChain");
|
||||
}
|
||||
|
||||
return typeid_cast<ExpressionActionsStep *>(steps.back().get())->actions_and_flags;
|
||||
return typeid_cast<ExpressionActionsStep *>(steps.back().get());
|
||||
}
|
||||
|
||||
ActionsAndProjectInputsFlagPtr getLastActions(bool allow_empty = false)
|
||||
{
|
||||
if (auto * step = getLastExpressionStep(allow_empty))
|
||||
return step->actions_and_flags;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Step & getLastStep()
|
||||
@ -294,7 +303,7 @@ struct ExpressionActionsChain : WithContext
|
||||
|
||||
Step & addStep(const NamesAndTypesList & columns)
|
||||
{
|
||||
return *steps.emplace_back(std::make_unique<ExpressionActionsStep>(std::make_shared<ActionsAndFlags>(ActionsDAG(columns), false, false)));
|
||||
return *steps.emplace_back(std::make_unique<ExpressionActionsStep>(std::make_shared<ActionsAndProjectInputsFlag>(ActionsDAG(columns), false)));
|
||||
}
|
||||
|
||||
std::string dumpChain() const;
|
||||
|
@ -891,7 +891,7 @@ ArrayJoinActionPtr ExpressionAnalyzer::addMultipleArrayJoinAction(ActionsDAG & a
|
||||
return std::make_shared<ArrayJoinAction>(result_columns, array_join_is_left, getContext());
|
||||
}
|
||||
|
||||
ArrayJoinActionPtr SelectQueryExpressionAnalyzer::appendArrayJoin(ExpressionActionsChain & chain, ActionsAndFlagsPtr & before_array_join, bool only_types)
|
||||
ArrayJoinActionPtr SelectQueryExpressionAnalyzer::appendArrayJoin(ExpressionActionsChain & chain, ActionsAndProjectInputsFlagPtr & before_array_join, bool only_types)
|
||||
{
|
||||
const auto * select_query = getSelectQuery();
|
||||
|
||||
@ -901,9 +901,9 @@ ArrayJoinActionPtr SelectQueryExpressionAnalyzer::appendArrayJoin(ExpressionActi
|
||||
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(sourceColumns());
|
||||
|
||||
getRootActions(array_join_expression_list, only_types, step.actions()->actions);
|
||||
getRootActions(array_join_expression_list, only_types, step.actions()->dag);
|
||||
|
||||
auto array_join = addMultipleArrayJoinAction(step.actions()->actions, is_array_join_left);
|
||||
auto array_join = addMultipleArrayJoinAction(step.actions()->dag, is_array_join_left);
|
||||
before_array_join = chain.getLastActions();
|
||||
|
||||
chain.steps.push_back(std::make_unique<ExpressionActionsChain::ArrayJoinStep>(array_join, step.getResultColumns()));
|
||||
@ -917,13 +917,13 @@ bool SelectQueryExpressionAnalyzer::appendJoinLeftKeys(ExpressionActionsChain &
|
||||
{
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(columns_after_array_join);
|
||||
|
||||
getRootActions(analyzedJoin().leftKeysList(), only_types, step.actions()->actions);
|
||||
getRootActions(analyzedJoin().leftKeysList(), only_types, step.actions()->dag);
|
||||
return true;
|
||||
}
|
||||
|
||||
JoinPtr SelectQueryExpressionAnalyzer::appendJoin(
|
||||
ExpressionActionsChain & chain,
|
||||
ActionsAndFlagsPtr & converting_join_columns)
|
||||
ActionsAndProjectInputsFlagPtr & converting_join_columns)
|
||||
{
|
||||
const ColumnsWithTypeAndName & left_sample_columns = chain.getLastStep().getResultColumns();
|
||||
|
||||
@ -932,8 +932,8 @@ JoinPtr SelectQueryExpressionAnalyzer::appendJoin(
|
||||
|
||||
if (converting_actions)
|
||||
{
|
||||
converting_join_columns = std::make_shared<ActionsAndFlags>();
|
||||
converting_join_columns->actions = std::move(*converting_actions);
|
||||
converting_join_columns = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
converting_join_columns->dag = std::move(*converting_actions);
|
||||
chain.steps.push_back(std::make_unique<ExpressionActionsChain::ExpressionActionsStep>(converting_join_columns));
|
||||
chain.addStep();
|
||||
}
|
||||
@ -1170,7 +1170,7 @@ JoinPtr SelectQueryExpressionAnalyzer::makeJoin(
|
||||
return join;
|
||||
}
|
||||
|
||||
ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendPrewhere(
|
||||
ActionsAndProjectInputsFlagPtr SelectQueryExpressionAnalyzer::appendPrewhere(
|
||||
ExpressionActionsChain & chain, bool only_types)
|
||||
{
|
||||
const auto * select_query = getSelectQuery();
|
||||
@ -1182,17 +1182,17 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendPrewhere(
|
||||
first_action_names = chain.steps.front()->getRequiredColumns().getNames();
|
||||
|
||||
auto & step = chain.lastStep(sourceColumns());
|
||||
getRootActions(select_query->prewhere(), only_types, step.actions()->actions);
|
||||
getRootActions(select_query->prewhere(), only_types, step.actions()->dag);
|
||||
String prewhere_column_name = select_query->prewhere()->getColumnName();
|
||||
step.addRequiredOutput(prewhere_column_name);
|
||||
|
||||
const auto & node = step.actions()->actions.findInOutputs(prewhere_column_name);
|
||||
const auto & node = step.actions()->dag.findInOutputs(prewhere_column_name);
|
||||
auto filter_type = node.result_type;
|
||||
if (!filter_type->canBeUsedInBooleanContext())
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER, "Invalid type for filter in PREWHERE: {}",
|
||||
filter_type->getName());
|
||||
|
||||
ActionsAndFlagsPtr prewhere_actions;
|
||||
ActionsAndProjectInputsFlagPtr prewhere_actions;
|
||||
{
|
||||
/// Remove unused source_columns from prewhere actions.
|
||||
ActionsDAG tmp_actions_dag(sourceColumns());
|
||||
@ -1208,7 +1208,7 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendPrewhere(
|
||||
NameSet required_source_columns(required_columns.begin(), required_columns.end());
|
||||
required_source_columns.insert(first_action_names.begin(), first_action_names.end());
|
||||
|
||||
auto names = step.actions()->actions.getNames();
|
||||
auto names = step.actions()->dag.getNames();
|
||||
NameSet name_set(names.begin(), names.end());
|
||||
|
||||
for (const auto & column : sourceColumns())
|
||||
@ -1217,13 +1217,13 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendPrewhere(
|
||||
|
||||
Names required_output(name_set.begin(), name_set.end());
|
||||
prewhere_actions = chain.getLastActions();
|
||||
prewhere_actions->actions.removeUnusedActions(required_output);
|
||||
prewhere_actions->dag.removeUnusedActions(required_output);
|
||||
}
|
||||
|
||||
{
|
||||
auto actions = std::make_shared<ActionsAndFlags>();
|
||||
auto actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
|
||||
auto required_columns = prewhere_actions->actions.getRequiredColumns();
|
||||
auto required_columns = prewhere_actions->dag.getRequiredColumns();
|
||||
NameSet prewhere_input_names;
|
||||
for (const auto & col : required_columns)
|
||||
prewhere_input_names.insert(col.name);
|
||||
@ -1267,11 +1267,11 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendPrewhere(
|
||||
}
|
||||
}
|
||||
|
||||
actions->actions = ActionsDAG(required_columns);
|
||||
actions->dag = ActionsDAG(required_columns);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColumnsWithTypeAndName columns = prewhere_actions->actions.getResultColumns();
|
||||
ColumnsWithTypeAndName columns = prewhere_actions->dag.getResultColumns();
|
||||
|
||||
for (const auto & column : sourceColumns())
|
||||
{
|
||||
@ -1282,7 +1282,7 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendPrewhere(
|
||||
}
|
||||
}
|
||||
|
||||
actions->actions = ActionsDAG(columns);
|
||||
actions->dag = ActionsDAG(columns);
|
||||
}
|
||||
|
||||
chain.steps.emplace_back(
|
||||
@ -1304,12 +1304,12 @@ bool SelectQueryExpressionAnalyzer::appendWhere(ExpressionActionsChain & chain,
|
||||
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(columns_after_join);
|
||||
|
||||
getRootActions(select_query->where(), only_types, step.actions()->actions);
|
||||
getRootActions(select_query->where(), only_types, step.actions()->dag);
|
||||
|
||||
auto where_column_name = select_query->where()->getColumnName();
|
||||
step.addRequiredOutput(where_column_name);
|
||||
|
||||
const auto & node = step.actions()->actions.findInOutputs(where_column_name);
|
||||
const auto & node = step.actions()->dag.findInOutputs(where_column_name);
|
||||
auto filter_type = node.result_type;
|
||||
if (!filter_type->canBeUsedInBooleanContext())
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER, "Invalid type for filter in WHERE: {}",
|
||||
@ -1336,7 +1336,7 @@ bool SelectQueryExpressionAnalyzer::appendGroupBy(ExpressionActionsChain & chain
|
||||
for (const auto & ast_element : ast->children)
|
||||
{
|
||||
step.addRequiredOutput(ast_element->getColumnName());
|
||||
getRootActions(ast_element, only_types, step.actions()->actions);
|
||||
getRootActions(ast_element, only_types, step.actions()->dag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1345,7 +1345,7 @@ bool SelectQueryExpressionAnalyzer::appendGroupBy(ExpressionActionsChain & chain
|
||||
for (const auto & ast : asts)
|
||||
{
|
||||
step.addRequiredOutput(ast->getColumnName());
|
||||
getRootActions(ast, only_types, step.actions()->actions);
|
||||
getRootActions(ast, only_types, step.actions()->dag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1391,7 +1391,7 @@ void SelectQueryExpressionAnalyzer::appendAggregateFunctionsArguments(Expression
|
||||
const ASTFunction & node = typeid_cast<const ASTFunction &>(*ast);
|
||||
if (node.arguments)
|
||||
for (auto & argument : node.arguments->children)
|
||||
getRootActions(argument, only_types, step.actions()->actions);
|
||||
getRootActions(argument, only_types, step.actions()->dag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1413,7 +1413,7 @@ void SelectQueryExpressionAnalyzer::appendWindowFunctionsArguments(
|
||||
// recursively together with (1b) as ASTFunction::window_definition.
|
||||
if (getSelectQuery()->window())
|
||||
{
|
||||
getRootActionsNoMakeSet(getSelectQuery()->window(), step.actions()->actions);
|
||||
getRootActionsNoMakeSet(getSelectQuery()->window(), step.actions()->dag);
|
||||
}
|
||||
|
||||
for (const auto & [_, w] : window_descriptions)
|
||||
@ -1424,7 +1424,7 @@ void SelectQueryExpressionAnalyzer::appendWindowFunctionsArguments(
|
||||
// definitions (1a).
|
||||
// Requiring a constant reference to a shared pointer to non-const AST
|
||||
// doesn't really look sane, but the visitor does indeed require it.
|
||||
getRootActionsNoMakeSet(f.function_node->clone(), step.actions()->actions);
|
||||
getRootActionsNoMakeSet(f.function_node->clone(), step.actions()->dag);
|
||||
|
||||
// (2b) Required function argument columns.
|
||||
for (const auto & a : f.function_node->arguments->children)
|
||||
@ -1446,7 +1446,7 @@ void SelectQueryExpressionAnalyzer::appendExpressionsAfterWindowFunctions(Expres
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(columns_after_window);
|
||||
|
||||
for (const auto & expression : syntax->expressions_with_window_function)
|
||||
getRootActionsForWindowFunctions(expression->clone(), true, step.actions()->actions);
|
||||
getRootActionsForWindowFunctions(expression->clone(), true, step.actions()->dag);
|
||||
}
|
||||
|
||||
void SelectQueryExpressionAnalyzer::appendGroupByModifiers(ActionsDAG & before_aggregation, ExpressionActionsChain & chain, bool /* only_types */)
|
||||
@ -1470,7 +1470,7 @@ void SelectQueryExpressionAnalyzer::appendGroupByModifiers(ActionsDAG & before_a
|
||||
ExpressionActionsChain::Step & step = chain.addStep(before_aggregation.getNamesAndTypesList());
|
||||
step.required_output = std::move(required_output);
|
||||
|
||||
step.actions()->actions = std::move(*ActionsDAG::makeConvertingActions(source_columns, result_columns, ActionsDAG::MatchColumnsMode::Position));
|
||||
step.actions()->dag = std::move(*ActionsDAG::makeConvertingActions(source_columns, result_columns, ActionsDAG::MatchColumnsMode::Position));
|
||||
}
|
||||
|
||||
void SelectQueryExpressionAnalyzer::appendSelectSkipWindowExpressions(ExpressionActionsChain::Step & step, ASTPtr const & node)
|
||||
@ -1501,7 +1501,7 @@ bool SelectQueryExpressionAnalyzer::appendHaving(ExpressionActionsChain & chain,
|
||||
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(aggregated_columns);
|
||||
|
||||
getRootActionsForHaving(select_query->having(), only_types, step.actions()->actions);
|
||||
getRootActionsForHaving(select_query->having(), only_types, step.actions()->dag);
|
||||
|
||||
step.addRequiredOutput(select_query->having()->getColumnName());
|
||||
|
||||
@ -1514,13 +1514,13 @@ void SelectQueryExpressionAnalyzer::appendSelect(ExpressionActionsChain & chain,
|
||||
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(aggregated_columns);
|
||||
|
||||
getRootActions(select_query->select(), only_types, step.actions()->actions);
|
||||
getRootActions(select_query->select(), only_types, step.actions()->dag);
|
||||
|
||||
for (const auto & child : select_query->select()->children)
|
||||
appendSelectSkipWindowExpressions(step, child);
|
||||
}
|
||||
|
||||
ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendOrderBy(ExpressionActionsChain & chain, bool only_types, bool optimize_read_in_order,
|
||||
ActionsAndProjectInputsFlagPtr SelectQueryExpressionAnalyzer::appendOrderBy(ExpressionActionsChain & chain, bool only_types, bool optimize_read_in_order,
|
||||
ManyExpressionActions & order_by_elements_actions)
|
||||
{
|
||||
const auto * select_query = getSelectQuery();
|
||||
@ -1544,7 +1544,7 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendOrderBy(ExpressionAction
|
||||
replaceForPositionalArguments(ast->children.at(0), select_query, ASTSelectQuery::Expression::ORDER_BY);
|
||||
}
|
||||
|
||||
getRootActions(select_query->orderBy(), only_types, step.actions()->actions);
|
||||
getRootActions(select_query->orderBy(), only_types, step.actions()->dag);
|
||||
|
||||
bool with_fill = false;
|
||||
|
||||
@ -1634,7 +1634,7 @@ bool SelectQueryExpressionAnalyzer::appendLimitBy(ExpressionActionsChain & chain
|
||||
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(aggregated_columns);
|
||||
|
||||
getRootActions(select_query->limitBy(), only_types, step.actions()->actions);
|
||||
getRootActions(select_query->limitBy(), only_types, step.actions()->dag);
|
||||
|
||||
NameSet existing_column_names;
|
||||
for (const auto & column : aggregated_columns)
|
||||
@ -1663,7 +1663,7 @@ bool SelectQueryExpressionAnalyzer::appendLimitBy(ExpressionActionsChain & chain
|
||||
return true;
|
||||
}
|
||||
|
||||
ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendProjectResult(ExpressionActionsChain & chain) const
|
||||
ActionsAndProjectInputsFlagPtr SelectQueryExpressionAnalyzer::appendProjectResult(ExpressionActionsChain & chain) const
|
||||
{
|
||||
const auto * select_query = getSelectQuery();
|
||||
|
||||
@ -1711,18 +1711,20 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendProjectResult(Expression
|
||||
}
|
||||
}
|
||||
|
||||
auto actions = chain.getLastActions();
|
||||
actions->actions.project(result_columns);
|
||||
auto * last_step = chain.getLastExpressionStep();
|
||||
auto & actions = last_step->actions_and_flags;
|
||||
actions->dag.project(result_columns);
|
||||
|
||||
if (!required_result_columns.empty())
|
||||
{
|
||||
result_columns.clear();
|
||||
for (const auto & column : required_result_columns)
|
||||
result_columns.emplace_back(column, std::string{});
|
||||
actions->actions.project(result_columns);
|
||||
actions->dag.project(result_columns);
|
||||
}
|
||||
|
||||
actions->project_input = actions->projected_output = true;
|
||||
actions->project_input = true;
|
||||
last_step->is_final_projection = true;
|
||||
return actions;
|
||||
}
|
||||
|
||||
@ -1730,7 +1732,7 @@ ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::appendProjectResult(Expression
|
||||
void ExpressionAnalyzer::appendExpression(ExpressionActionsChain & chain, const ASTPtr & expr, bool only_types)
|
||||
{
|
||||
ExpressionActionsChain::Step & step = chain.lastStep(sourceColumns());
|
||||
getRootActions(expr, only_types, step.actions()->actions);
|
||||
getRootActions(expr, only_types, step.actions()->dag);
|
||||
step.addRequiredOutput(expr->getColumnName());
|
||||
}
|
||||
|
||||
@ -1813,7 +1815,7 @@ std::unique_ptr<QueryPlan> SelectQueryExpressionAnalyzer::getJoinedPlan()
|
||||
return std::move(joined_plan);
|
||||
}
|
||||
|
||||
ActionsAndFlagsPtr SelectQueryExpressionAnalyzer::simpleSelectActions()
|
||||
ActionsAndProjectInputsFlagPtr SelectQueryExpressionAnalyzer::simpleSelectActions()
|
||||
{
|
||||
ExpressionActionsChain new_chain(getContext());
|
||||
appendSelect(new_chain, false);
|
||||
@ -1853,7 +1855,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
ssize_t where_step_num = -1;
|
||||
ssize_t having_step_num = -1;
|
||||
|
||||
ActionsAndFlagsPtr prewhere_dag_and_flags;
|
||||
ActionsAndProjectInputsFlagPtr prewhere_dag_and_flags;
|
||||
|
||||
auto finalize_chain = [&](ExpressionActionsChain & chain) -> ColumnsWithTypeAndName
|
||||
{
|
||||
@ -1861,7 +1863,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
{
|
||||
ExpressionActionsChain::Step & step = *chain.steps.at(prewhere_step_num);
|
||||
|
||||
auto prewhere_required_columns = prewhere_dag_and_flags->actions.getRequiredColumnsNames();
|
||||
auto prewhere_required_columns = prewhere_dag_and_flags->dag.getRequiredColumnsNames();
|
||||
NameSet required_source_columns(prewhere_required_columns.begin(), prewhere_required_columns.end());
|
||||
/// Add required columns to required output in order not to remove them after prewhere execution.
|
||||
/// TODO: add sampling and final execution to common chain.
|
||||
@ -1876,7 +1878,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
|
||||
if (prewhere_dag_and_flags)
|
||||
{
|
||||
auto dag = std::make_shared<ActionsDAG>(std::move(prewhere_dag_and_flags->actions));
|
||||
auto dag = std::make_shared<ActionsDAG>(std::move(prewhere_dag_and_flags->dag));
|
||||
prewhere_info = std::make_shared<PrewhereInfo>(std::move(dag), query.prewhere()->getColumnName());
|
||||
prewhere_dag_and_flags.reset();
|
||||
}
|
||||
@ -1936,12 +1938,12 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
/// Prewhere is always the first one.
|
||||
prewhere_step_num = 0;
|
||||
|
||||
if (allowEarlyConstantFolding(prewhere_dag_and_flags->actions, settings))
|
||||
if (allowEarlyConstantFolding(prewhere_dag_and_flags->dag, settings))
|
||||
{
|
||||
Block before_prewhere_sample = source_header;
|
||||
if (sanitizeBlock(before_prewhere_sample))
|
||||
{
|
||||
auto dag = prewhere_dag_and_flags->actions.clone();
|
||||
auto dag = prewhere_dag_and_flags->dag.clone();
|
||||
ExpressionActions(
|
||||
dag,
|
||||
ExpressionActionsSettings::fromSettings(context->getSettingsRef())).execute(before_prewhere_sample);
|
||||
@ -1967,7 +1969,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
{
|
||||
where_step_num = chain.steps.size() - 1;
|
||||
before_where = chain.getLastActions();
|
||||
if (allowEarlyConstantFolding(before_where->actions, settings))
|
||||
if (allowEarlyConstantFolding(before_where->dag, settings))
|
||||
{
|
||||
Block before_where_sample;
|
||||
if (chain.steps.size() > 1)
|
||||
@ -1977,7 +1979,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
if (sanitizeBlock(before_where_sample))
|
||||
{
|
||||
ExpressionActions(
|
||||
before_where->actions.clone(),
|
||||
before_where->dag.clone(),
|
||||
ExpressionActionsSettings::fromSettings(context->getSettingsRef())).execute(before_where_sample);
|
||||
|
||||
auto & column_elem
|
||||
@ -2003,7 +2005,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
before_aggregation = chain.getLastActions();
|
||||
|
||||
if (settings.group_by_use_nulls)
|
||||
query_analyzer.appendGroupByModifiers(before_aggregation->actions, chain, only_types);
|
||||
query_analyzer.appendGroupByModifiers(before_aggregation->dag, chain, only_types);
|
||||
|
||||
auto columns_before_aggregation = finalize_chain(chain);
|
||||
|
||||
@ -2050,7 +2052,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
true);
|
||||
|
||||
auto & step = chain.lastStep(query_analyzer.aggregated_columns);
|
||||
auto & actions = step.actions()->actions;
|
||||
auto & actions = step.actions()->dag;
|
||||
actions = std::move(*ActionsDAG::merge(std::move(actions), std::move(*converting)));
|
||||
}
|
||||
}
|
||||
@ -2087,13 +2089,13 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
// the main SELECT, similar to what we do for aggregate functions.
|
||||
if (has_window)
|
||||
{
|
||||
query_analyzer.makeWindowDescriptions(chain.getLastActions()->actions);
|
||||
query_analyzer.makeWindowDescriptions(chain.getLastActions()->dag);
|
||||
|
||||
query_analyzer.appendWindowFunctionsArguments(chain, only_types || !first_stage);
|
||||
|
||||
// Build a list of output columns of the window step.
|
||||
// 1) We need the columns that are the output of ExpressionActions.
|
||||
for (const auto & x : chain.getLastActions()->actions.getNamesAndTypesList())
|
||||
for (const auto & x : chain.getLastActions()->dag.getNamesAndTypesList())
|
||||
{
|
||||
query_analyzer.columns_after_window.push_back(x);
|
||||
}
|
||||
@ -2130,7 +2132,7 @@ ExpressionAnalysisResult::ExpressionAnalysisResult(
|
||||
finalize_chain(chain);
|
||||
|
||||
query_analyzer.appendExpressionsAfterWindowFunctions(chain, only_types || !first_stage);
|
||||
for (const auto & x : chain.getLastActions()->actions.getNamesAndTypesList())
|
||||
for (const auto & x : chain.getLastActions()->dag.getNamesAndTypesList())
|
||||
{
|
||||
query_analyzer.columns_after_window.push_back(x);
|
||||
}
|
||||
@ -2254,7 +2256,7 @@ std::string ExpressionAnalysisResult::dump() const
|
||||
|
||||
if (before_array_join)
|
||||
{
|
||||
ss << "before_array_join " << before_array_join->actions.dumpDAG() << "\n";
|
||||
ss << "before_array_join " << before_array_join->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (array_join)
|
||||
@ -2264,12 +2266,12 @@ std::string ExpressionAnalysisResult::dump() const
|
||||
|
||||
if (before_join)
|
||||
{
|
||||
ss << "before_join " << before_join->actions.dumpDAG() << "\n";
|
||||
ss << "before_join " << before_join->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (before_where)
|
||||
{
|
||||
ss << "before_where " << before_where->actions.dumpDAG() << "\n";
|
||||
ss << "before_where " << before_where->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (prewhere_info)
|
||||
@ -2284,32 +2286,32 @@ std::string ExpressionAnalysisResult::dump() const
|
||||
|
||||
if (before_aggregation)
|
||||
{
|
||||
ss << "before_aggregation " << before_aggregation->actions.dumpDAG() << "\n";
|
||||
ss << "before_aggregation " << before_aggregation->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (before_having)
|
||||
{
|
||||
ss << "before_having " << before_having->actions.dumpDAG() << "\n";
|
||||
ss << "before_having " << before_having->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (before_window)
|
||||
{
|
||||
ss << "before_window " << before_window->actions.dumpDAG() << "\n";
|
||||
ss << "before_window " << before_window->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (before_order_by)
|
||||
{
|
||||
ss << "before_order_by " << before_order_by->actions.dumpDAG() << "\n";
|
||||
ss << "before_order_by " << before_order_by->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (before_limit_by)
|
||||
{
|
||||
ss << "before_limit_by " << before_limit_by->actions.dumpDAG() << "\n";
|
||||
ss << "before_limit_by " << before_limit_by->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (final_projection)
|
||||
{
|
||||
ss << "final_projection " << final_projection->actions.dumpDAG() << "\n";
|
||||
ss << "final_projection " << final_projection->dag.dumpDAG() << "\n";
|
||||
}
|
||||
|
||||
if (!selected_columns.empty())
|
||||
|
@ -231,20 +231,20 @@ struct ExpressionAnalysisResult
|
||||
|
||||
bool use_grouping_set_key = false;
|
||||
|
||||
ActionsAndFlagsPtr before_array_join;
|
||||
ActionsAndProjectInputsFlagPtr before_array_join;
|
||||
ArrayJoinActionPtr array_join;
|
||||
ActionsAndFlagsPtr before_join;
|
||||
ActionsAndFlagsPtr converting_join_columns;
|
||||
ActionsAndProjectInputsFlagPtr before_join;
|
||||
ActionsAndProjectInputsFlagPtr converting_join_columns;
|
||||
JoinPtr join;
|
||||
ActionsAndFlagsPtr before_where;
|
||||
ActionsAndFlagsPtr before_aggregation;
|
||||
ActionsAndFlagsPtr before_having;
|
||||
ActionsAndProjectInputsFlagPtr before_where;
|
||||
ActionsAndProjectInputsFlagPtr before_aggregation;
|
||||
ActionsAndProjectInputsFlagPtr before_having;
|
||||
String having_column_name;
|
||||
bool remove_having_filter = false;
|
||||
ActionsAndFlagsPtr before_window;
|
||||
ActionsAndFlagsPtr before_order_by;
|
||||
ActionsAndFlagsPtr before_limit_by;
|
||||
ActionsAndFlagsPtr final_projection;
|
||||
ActionsAndProjectInputsFlagPtr before_window;
|
||||
ActionsAndProjectInputsFlagPtr before_order_by;
|
||||
ActionsAndProjectInputsFlagPtr before_limit_by;
|
||||
ActionsAndProjectInputsFlagPtr final_projection;
|
||||
|
||||
/// Columns from the SELECT list, before renaming them to aliases. Used to
|
||||
/// perform SELECT DISTINCT.
|
||||
@ -351,12 +351,12 @@ public:
|
||||
/// Tables that will need to be sent to remote servers for distributed query processing.
|
||||
const TemporaryTablesMapping & getExternalTables() const { return external_tables; }
|
||||
|
||||
ActionsAndFlagsPtr simpleSelectActions();
|
||||
ActionsAndProjectInputsFlagPtr simpleSelectActions();
|
||||
|
||||
/// These appends are public only for tests
|
||||
void appendSelect(ExpressionActionsChain & chain, bool only_types);
|
||||
/// Deletes all columns except mentioned by SELECT, arranges the remaining columns and renames them to aliases.
|
||||
ActionsAndFlagsPtr appendProjectResult(ExpressionActionsChain & chain) const;
|
||||
ActionsAndProjectInputsFlagPtr appendProjectResult(ExpressionActionsChain & chain) const;
|
||||
|
||||
private:
|
||||
StorageMetadataPtr metadata_snapshot;
|
||||
@ -386,13 +386,13 @@ private:
|
||||
*/
|
||||
|
||||
/// Before aggregation:
|
||||
ArrayJoinActionPtr appendArrayJoin(ExpressionActionsChain & chain, ActionsAndFlagsPtr & before_array_join, bool only_types);
|
||||
ArrayJoinActionPtr appendArrayJoin(ExpressionActionsChain & chain, ActionsAndProjectInputsFlagPtr & before_array_join, bool only_types);
|
||||
bool appendJoinLeftKeys(ExpressionActionsChain & chain, bool only_types);
|
||||
JoinPtr appendJoin(ExpressionActionsChain & chain, ActionsAndFlagsPtr & converting_join_columns);
|
||||
JoinPtr appendJoin(ExpressionActionsChain & chain, ActionsAndProjectInputsFlagPtr & converting_join_columns);
|
||||
|
||||
/// remove_filter is set in ExpressionActionsChain::finalize();
|
||||
/// Columns in `additional_required_columns` will not be removed (they can be used for e.g. sampling or FINAL modifier).
|
||||
ActionsAndFlagsPtr appendPrewhere(ExpressionActionsChain & chain, bool only_types);
|
||||
ActionsAndProjectInputsFlagPtr appendPrewhere(ExpressionActionsChain & chain, bool only_types);
|
||||
bool appendWhere(ExpressionActionsChain & chain, bool only_types);
|
||||
bool appendGroupBy(ExpressionActionsChain & chain, bool only_types, bool optimize_aggregation_in_order, ManyExpressionActions &);
|
||||
void appendAggregateFunctionsArguments(ExpressionActionsChain & chain, bool only_types);
|
||||
@ -406,7 +406,7 @@ private:
|
||||
/// After aggregation:
|
||||
bool appendHaving(ExpressionActionsChain & chain, bool only_types);
|
||||
/// appendSelect
|
||||
ActionsAndFlagsPtr appendOrderBy(ExpressionActionsChain & chain, bool only_types, bool optimize_read_in_order, ManyExpressionActions &);
|
||||
ActionsAndProjectInputsFlagPtr appendOrderBy(ExpressionActionsChain & chain, bool only_types, bool optimize_read_in_order, ManyExpressionActions &);
|
||||
bool appendLimitBy(ExpressionActionsChain & chain, bool only_types);
|
||||
/// appendProjectResult
|
||||
};
|
||||
|
@ -175,7 +175,7 @@ FilterDAGInfoPtr generateFilterActions(
|
||||
/// Using separate expression analyzer to prevent any possible alias injection
|
||||
auto syntax_result = TreeRewriter(context).analyzeSelect(query_ast, TreeRewriterResult({}, storage, storage_snapshot));
|
||||
SelectQueryExpressionAnalyzer analyzer(query_ast, syntax_result, context, metadata_snapshot, {}, false, {}, prepared_sets);
|
||||
filter_info->actions = std::make_unique<ActionsDAG>(std::move(analyzer.simpleSelectActions()->actions));
|
||||
filter_info->actions = std::make_unique<ActionsDAG>(std::move(analyzer.simpleSelectActions()->dag));
|
||||
|
||||
filter_info->column_name = expr_list->children.at(0)->getColumnName();
|
||||
filter_info->actions->removeUnusedActions(NameSet{filter_info->column_name});
|
||||
@ -1077,15 +1077,15 @@ Block InterpreterSelectQuery::getSampleBlockImpl()
|
||||
// with this code. See
|
||||
// https://github.com/ClickHouse/ClickHouse/issues/19857 for details.
|
||||
if (analysis_result.before_window)
|
||||
return analysis_result.before_window->actions.getResultColumns();
|
||||
return analysis_result.before_window->dag.getResultColumns();
|
||||
|
||||
// NOTE: should not handle before_limit_by specially since
|
||||
// WithMergeableState does not process LIMIT BY
|
||||
|
||||
return analysis_result.before_order_by->actions.getResultColumns();
|
||||
return analysis_result.before_order_by->dag.getResultColumns();
|
||||
}
|
||||
|
||||
Block header = analysis_result.before_aggregation->actions.getResultColumns();
|
||||
Block header = analysis_result.before_aggregation->dag.getResultColumns();
|
||||
|
||||
Block res;
|
||||
|
||||
@ -1123,18 +1123,18 @@ Block InterpreterSelectQuery::getSampleBlockImpl()
|
||||
// It's different from selected_columns, see the comment above for
|
||||
// WithMergeableState stage.
|
||||
if (analysis_result.before_window)
|
||||
return analysis_result.before_window->actions.getResultColumns();
|
||||
return analysis_result.before_window->dag.getResultColumns();
|
||||
|
||||
// In case of query on remote shards executed up to
|
||||
// WithMergeableStateAfterAggregation*, they can process LIMIT BY,
|
||||
// since the initiator will not apply LIMIT BY again.
|
||||
if (analysis_result.before_limit_by)
|
||||
return analysis_result.before_limit_by->actions.getResultColumns();
|
||||
return analysis_result.before_limit_by->dag.getResultColumns();
|
||||
|
||||
return analysis_result.before_order_by->actions.getResultColumns();
|
||||
return analysis_result.before_order_by->dag.getResultColumns();
|
||||
}
|
||||
|
||||
return analysis_result.final_projection->actions.getResultColumns();
|
||||
return analysis_result.final_projection->dag.getResultColumns();
|
||||
}
|
||||
|
||||
|
||||
@ -2313,7 +2313,7 @@ std::optional<UInt64> InterpreterSelectQuery::getTrivialCount(UInt64 max_paralle
|
||||
}
|
||||
if (analysis_result.hasWhere())
|
||||
{
|
||||
filter_nodes.push_back(&analysis_result.before_where->actions.findInOutputs(analysis_result.where_column_name));
|
||||
filter_nodes.push_back(&analysis_result.before_where->dag.findInOutputs(analysis_result.where_column_name));
|
||||
}
|
||||
|
||||
auto filter_actions_dag = ActionsDAG::buildFilterActionsDAG(filter_nodes);
|
||||
@ -2379,7 +2379,7 @@ void InterpreterSelectQuery::executeFetchColumns(QueryProcessingStage::Enum proc
|
||||
auto column = ColumnAggregateFunction::create(func);
|
||||
column->insertFrom(place);
|
||||
|
||||
Block header = analysis_result.before_aggregation->actions.getResultColumns();
|
||||
Block header = analysis_result.before_aggregation->dag.getResultColumns();
|
||||
size_t arguments_size = desc.argument_names.size();
|
||||
DataTypes argument_types(arguments_size);
|
||||
for (size_t j = 0; j < arguments_size; ++j)
|
||||
@ -2576,9 +2576,9 @@ void InterpreterSelectQuery::executeFetchColumns(QueryProcessingStage::Enum proc
|
||||
}
|
||||
}
|
||||
|
||||
void InterpreterSelectQuery::executeWhere(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, bool remove_filter)
|
||||
void InterpreterSelectQuery::executeWhere(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, bool remove_filter)
|
||||
{
|
||||
auto dag = expression->actions.clone();
|
||||
auto dag = expression->dag.clone();
|
||||
if (expression->project_input)
|
||||
dag->appendInputsForUnusedColumns(query_plan.getCurrentDataStream().header);
|
||||
|
||||
@ -2657,7 +2657,7 @@ static GroupingSetsParamsList getAggregatorGroupingSetsParams(const SelectQueryE
|
||||
return result;
|
||||
}
|
||||
|
||||
void InterpreterSelectQuery::executeAggregation(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, bool overflow_row, bool final, InputOrderInfoPtr group_by_info)
|
||||
void InterpreterSelectQuery::executeAggregation(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, bool overflow_row, bool final, InputOrderInfoPtr group_by_info)
|
||||
{
|
||||
executeExpression(query_plan, expression, "Before GROUP BY");
|
||||
|
||||
@ -2750,9 +2750,9 @@ void InterpreterSelectQuery::executeMergeAggregated(QueryPlan & query_plan, bool
|
||||
}
|
||||
|
||||
|
||||
void InterpreterSelectQuery::executeHaving(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, bool remove_filter)
|
||||
void InterpreterSelectQuery::executeHaving(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, bool remove_filter)
|
||||
{
|
||||
auto dag = expression->actions.clone();
|
||||
auto dag = expression->dag.clone();
|
||||
if (expression->project_input)
|
||||
dag->appendInputsForUnusedColumns(query_plan.getCurrentDataStream().header);
|
||||
|
||||
@ -2765,12 +2765,12 @@ void InterpreterSelectQuery::executeHaving(QueryPlan & query_plan, const Actions
|
||||
|
||||
|
||||
void InterpreterSelectQuery::executeTotalsAndHaving(
|
||||
QueryPlan & query_plan, bool has_having, const ActionsAndFlagsPtr & expression, bool remove_filter, bool overflow_row, bool final)
|
||||
QueryPlan & query_plan, bool has_having, const ActionsAndProjectInputsFlagPtr & expression, bool remove_filter, bool overflow_row, bool final)
|
||||
{
|
||||
ActionsDAGPtr dag;
|
||||
if (expression)
|
||||
{
|
||||
dag = expression->actions.clone();
|
||||
dag = expression->dag.clone();
|
||||
if (expression->project_input)
|
||||
dag->appendInputsForUnusedColumns(query_plan.getCurrentDataStream().header);
|
||||
}
|
||||
@ -2814,12 +2814,12 @@ void InterpreterSelectQuery::executeRollupOrCube(QueryPlan & query_plan, Modific
|
||||
query_plan.addStep(std::move(step));
|
||||
}
|
||||
|
||||
void InterpreterSelectQuery::executeExpression(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, const std::string & description)
|
||||
void InterpreterSelectQuery::executeExpression(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, const std::string & description)
|
||||
{
|
||||
if (!expression)
|
||||
return;
|
||||
|
||||
auto dag = expression->actions.clone();
|
||||
auto dag = expression->dag.clone();
|
||||
if (expression->project_input)
|
||||
dag->appendInputsForUnusedColumns(query_plan.getCurrentDataStream().header);
|
||||
|
||||
@ -2993,7 +2993,7 @@ void InterpreterSelectQuery::executeMergeSorted(QueryPlan & query_plan, const st
|
||||
}
|
||||
|
||||
|
||||
void InterpreterSelectQuery::executeProjection(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression)
|
||||
void InterpreterSelectQuery::executeProjection(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression)
|
||||
{
|
||||
executeExpression(query_plan, expression, "Projection");
|
||||
}
|
||||
|
@ -174,13 +174,13 @@ private:
|
||||
|
||||
/// Different stages of query execution.
|
||||
void executeFetchColumns(QueryProcessingStage::Enum processing_stage, QueryPlan & query_plan);
|
||||
void executeWhere(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, bool remove_filter);
|
||||
void executeWhere(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, bool remove_filter);
|
||||
void executeAggregation(
|
||||
QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, bool overflow_row, bool final, InputOrderInfoPtr group_by_info);
|
||||
QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, bool overflow_row, bool final, InputOrderInfoPtr group_by_info);
|
||||
void executeMergeAggregated(QueryPlan & query_plan, bool overflow_row, bool final, bool has_grouping_sets);
|
||||
void executeTotalsAndHaving(QueryPlan & query_plan, bool has_having, const ActionsAndFlagsPtr & expression, bool remove_filter, bool overflow_row, bool final);
|
||||
void executeHaving(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, bool remove_filter);
|
||||
static void executeExpression(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression, const std::string & description);
|
||||
void executeTotalsAndHaving(QueryPlan & query_plan, bool has_having, const ActionsAndProjectInputsFlagPtr & expression, bool remove_filter, bool overflow_row, bool final);
|
||||
void executeHaving(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, bool remove_filter);
|
||||
static void executeExpression(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression, const std::string & description);
|
||||
/// FIXME should go through ActionsDAG to behave as a proper function
|
||||
void executeWindow(QueryPlan & query_plan);
|
||||
void executeOrder(QueryPlan & query_plan, InputOrderInfoPtr sorting_info);
|
||||
@ -191,7 +191,7 @@ private:
|
||||
void executeLimitBy(QueryPlan & query_plan);
|
||||
void executeLimit(QueryPlan & query_plan);
|
||||
void executeOffset(QueryPlan & query_plan);
|
||||
static void executeProjection(QueryPlan & query_plan, const ActionsAndFlagsPtr & expression);
|
||||
static void executeProjection(QueryPlan & query_plan, const ActionsAndProjectInputsFlagPtr & expression);
|
||||
void executeDistinct(QueryPlan & query_plan, bool before_order, Names columns, bool pre_distinct);
|
||||
void executeExtremes(QueryPlan & query_plan);
|
||||
void executeSubqueriesInSetsAndJoins(QueryPlan & query_plan);
|
||||
|
@ -1137,9 +1137,9 @@ void MutationsInterpreter::prepareMutationStages(std::vector<Stage> & prepared_s
|
||||
for (const auto & kv : stage.column_to_updated)
|
||||
{
|
||||
auto column_name = kv.second->getColumnName();
|
||||
const auto & dag_node = actions->actions.findInOutputs(column_name);
|
||||
const auto & alias = actions->actions.addAlias(dag_node, kv.first);
|
||||
actions->actions.addOrReplaceInOutputs(alias);
|
||||
const auto & dag_node = actions->dag.findInOutputs(column_name);
|
||||
const auto & alias = actions->dag.addAlias(dag_node, kv.first);
|
||||
actions->dag.addOrReplaceInOutputs(alias);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1202,7 +1202,7 @@ void MutationsInterpreter::Source::read(
|
||||
{
|
||||
ActionsDAG::NodeRawConstPtrs nodes(num_filters);
|
||||
for (size_t i = 0; i < num_filters; ++i)
|
||||
nodes[i] = &steps[i]->actions()->actions.findInOutputs(names[i]);
|
||||
nodes[i] = &steps[i]->actions()->dag.findInOutputs(names[i]);
|
||||
|
||||
filter = ActionsDAG::buildFilterActionsDAG(nodes);
|
||||
}
|
||||
@ -1273,12 +1273,12 @@ QueryPipelineBuilder MutationsInterpreter::addStreamsForLaterStages(const std::v
|
||||
for (size_t i = 0; i < stage.expressions_chain.steps.size(); ++i)
|
||||
{
|
||||
const auto & step = stage.expressions_chain.steps[i];
|
||||
if (step->actions()->actions.hasArrayJoin())
|
||||
if (step->actions()->dag.hasArrayJoin())
|
||||
throw Exception(ErrorCodes::UNEXPECTED_EXPRESSION, "arrayJoin is not allowed in mutations");
|
||||
|
||||
if (i < stage.filter_column_names.size())
|
||||
{
|
||||
auto dag = step->actions()->actions.clone();
|
||||
auto dag = step->actions()->dag.clone();
|
||||
if (step->actions()->project_input)
|
||||
dag->appendInputsForUnusedColumns(plan.getCurrentDataStream().header);
|
||||
/// Execute DELETEs.
|
||||
@ -1286,7 +1286,7 @@ QueryPipelineBuilder MutationsInterpreter::addStreamsForLaterStages(const std::v
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dag = step->actions()->actions.clone();
|
||||
auto dag = step->actions()->dag.clone();
|
||||
if (step->actions()->project_input)
|
||||
dag->appendInputsForUnusedColumns(plan.getCurrentDataStream().header);
|
||||
/// Execute UPDATE or final projection.
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
ActionsChainStep::ActionsChainStep(ActionsAndFlagsPtr actions_,
|
||||
ActionsChainStep::ActionsChainStep(ActionsAndProjectInputsFlagPtr actions_,
|
||||
bool use_actions_nodes_as_output_columns_,
|
||||
ColumnsWithTypeAndName additional_output_columns_)
|
||||
: actions(std::move(actions_))
|
||||
@ -28,12 +28,12 @@ void ActionsChainStep::finalizeInputAndOutputColumns(const NameSet & child_input
|
||||
auto child_input_columns_copy = child_input_columns;
|
||||
|
||||
std::unordered_set<std::string_view> output_nodes_names;
|
||||
output_nodes_names.reserve(actions->actions.getOutputs().size());
|
||||
output_nodes_names.reserve(actions->dag.getOutputs().size());
|
||||
|
||||
for (auto & output_node : actions->actions.getOutputs())
|
||||
for (auto & output_node : actions->dag.getOutputs())
|
||||
output_nodes_names.insert(output_node->result_name);
|
||||
|
||||
for (const auto & node : actions->actions.getNodes())
|
||||
for (const auto & node : actions->dag.getNodes())
|
||||
{
|
||||
auto it = child_input_columns_copy.find(node.result_name);
|
||||
if (it == child_input_columns_copy.end())
|
||||
@ -45,11 +45,11 @@ void ActionsChainStep::finalizeInputAndOutputColumns(const NameSet & child_input
|
||||
if (output_nodes_names.contains(node.result_name))
|
||||
continue;
|
||||
|
||||
actions->actions.getOutputs().push_back(&node);
|
||||
actions->dag.getOutputs().push_back(&node);
|
||||
output_nodes_names.insert(node.result_name);
|
||||
}
|
||||
|
||||
actions->actions.removeUnusedActions();
|
||||
actions->dag.removeUnusedActions();
|
||||
/// TODO: Analyzer fix ActionsDAG input and constant nodes with same name
|
||||
actions->project_input = true;
|
||||
initialize();
|
||||
@ -58,7 +58,7 @@ void ActionsChainStep::finalizeInputAndOutputColumns(const NameSet & child_input
|
||||
void ActionsChainStep::dump(WriteBuffer & buffer) const
|
||||
{
|
||||
buffer << "DAG" << '\n';
|
||||
buffer << actions->actions.dumpDAG();
|
||||
buffer << actions->dag.dumpDAG();
|
||||
|
||||
if (!available_output_columns.empty())
|
||||
{
|
||||
@ -84,7 +84,7 @@ String ActionsChainStep::dump() const
|
||||
|
||||
void ActionsChainStep::initialize()
|
||||
{
|
||||
auto required_columns_names = actions->actions.getRequiredColumnsNames();
|
||||
auto required_columns_names = actions->dag.getRequiredColumnsNames();
|
||||
input_columns_names = NameSet(required_columns_names.begin(), required_columns_names.end());
|
||||
|
||||
available_output_columns.clear();
|
||||
@ -93,7 +93,7 @@ void ActionsChainStep::initialize()
|
||||
{
|
||||
std::unordered_set<std::string_view> available_output_columns_names;
|
||||
|
||||
for (const auto & node : actions->actions.getNodes())
|
||||
for (const auto & node : actions->dag.getNodes())
|
||||
{
|
||||
if (available_output_columns_names.contains(node.result_name))
|
||||
continue;
|
||||
|
@ -48,18 +48,18 @@ public:
|
||||
* If use_actions_nodes_as_output_columns = true output columns are initialized using actions dag nodes.
|
||||
* If additional output columns are specified they are added to output columns.
|
||||
*/
|
||||
explicit ActionsChainStep(ActionsAndFlagsPtr actions_,
|
||||
explicit ActionsChainStep(ActionsAndProjectInputsFlagPtr actions_,
|
||||
bool use_actions_nodes_as_output_columns = true,
|
||||
ColumnsWithTypeAndName additional_output_columns_ = {});
|
||||
|
||||
/// Get actions
|
||||
ActionsAndFlagsPtr & getActions()
|
||||
ActionsAndProjectInputsFlagPtr & getActions()
|
||||
{
|
||||
return actions;
|
||||
}
|
||||
|
||||
/// Get actions
|
||||
const ActionsAndFlagsPtr & getActions() const
|
||||
const ActionsAndProjectInputsFlagPtr & getActions() const
|
||||
{
|
||||
return actions;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public:
|
||||
private:
|
||||
void initialize();
|
||||
|
||||
ActionsAndFlagsPtr actions;
|
||||
ActionsAndProjectInputsFlagPtr actions;
|
||||
|
||||
bool use_actions_nodes_as_output_columns = true;
|
||||
|
||||
|
@ -329,11 +329,11 @@ public:
|
||||
};
|
||||
|
||||
void addExpressionStep(QueryPlan & query_plan,
|
||||
const ActionsAndFlagsPtr & expression_actions,
|
||||
const ActionsAndProjectInputsFlagPtr & expression_actions,
|
||||
const std::string & step_description,
|
||||
std::vector<ActionsDAGPtr> & result_actions_to_execute)
|
||||
{
|
||||
auto actions = expression_actions->actions.clone();
|
||||
auto actions = expression_actions->dag.clone();
|
||||
if (expression_actions->project_input)
|
||||
actions->appendInputsForUnusedColumns(query_plan.getCurrentDataStream().header);
|
||||
|
||||
@ -348,7 +348,7 @@ void addFilterStep(QueryPlan & query_plan,
|
||||
const std::string & step_description,
|
||||
std::vector<ActionsDAGPtr> & result_actions_to_execute)
|
||||
{
|
||||
auto actions = filter_analysis_result.filter_actions->actions.clone();
|
||||
auto actions = filter_analysis_result.filter_actions->dag.clone();
|
||||
if (filter_analysis_result.filter_actions->project_input)
|
||||
actions->appendInputsForUnusedColumns(query_plan.getCurrentDataStream().header);
|
||||
|
||||
@ -556,7 +556,7 @@ void addTotalsHavingStep(QueryPlan & query_plan,
|
||||
ActionsDAGPtr actions;
|
||||
if (having_analysis_result.filter_actions)
|
||||
{
|
||||
actions = having_analysis_result.filter_actions->actions.clone();
|
||||
actions = having_analysis_result.filter_actions->dag.clone();
|
||||
if (having_analysis_result.filter_actions->project_input)
|
||||
actions->appendInputsForUnusedColumns(query_plan.getCurrentDataStream().header);
|
||||
|
||||
|
@ -45,10 +45,10 @@ std::optional<FilterAnalysisResult> analyzeFilter(const QueryTreeNodePtr & filte
|
||||
{
|
||||
FilterAnalysisResult result;
|
||||
|
||||
result.filter_actions = std::make_shared<ActionsAndFlags>();
|
||||
result.filter_actions->actions = buildActionsDAGFromExpressionNode(filter_expression_node, input_columns, planner_context);
|
||||
result.filter_actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
result.filter_actions->dag = buildActionsDAGFromExpressionNode(filter_expression_node, input_columns, planner_context);
|
||||
|
||||
const auto * output = result.filter_actions->actions.getOutputs().at(0);
|
||||
const auto * output = result.filter_actions->dag.getOutputs().at(0);
|
||||
if (output->column && ConstantFilterDescription(*output->column).always_true)
|
||||
return {};
|
||||
|
||||
@ -118,9 +118,9 @@ std::optional<AggregationAnalysisResult> analyzeAggregation(const QueryTreeNodeP
|
||||
|
||||
Names aggregation_keys;
|
||||
|
||||
ActionsAndFlagsPtr before_aggregation_actions = std::make_shared<ActionsAndFlags>();
|
||||
before_aggregation_actions->actions = ActionsDAG(input_columns);
|
||||
before_aggregation_actions->actions.getOutputs().clear();
|
||||
ActionsAndProjectInputsFlagPtr before_aggregation_actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
before_aggregation_actions->dag = ActionsDAG(input_columns);
|
||||
before_aggregation_actions->dag.getOutputs().clear();
|
||||
|
||||
std::unordered_set<std::string_view> before_aggregation_actions_output_node_names;
|
||||
|
||||
@ -155,7 +155,7 @@ std::optional<AggregationAnalysisResult> analyzeAggregation(const QueryTreeNodeP
|
||||
if (constant_key && !aggregates_descriptions.empty() && (!check_constants_for_group_by_key || canRemoveConstantFromGroupByKey(*constant_key)))
|
||||
continue;
|
||||
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_aggregation_actions->actions, grouping_set_key_node);
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_aggregation_actions->dag, grouping_set_key_node);
|
||||
aggregation_keys.reserve(expression_dag_nodes.size());
|
||||
|
||||
for (auto & expression_dag_node : expression_dag_nodes)
|
||||
@ -168,7 +168,7 @@ std::optional<AggregationAnalysisResult> analyzeAggregation(const QueryTreeNodeP
|
||||
auto column_after_aggregation = group_by_use_nulls && expression_dag_node->column != nullptr ? makeNullableSafe(expression_dag_node->column) : expression_dag_node->column;
|
||||
available_columns_after_aggregation.emplace_back(std::move(column_after_aggregation), expression_type_after_aggregation, expression_dag_node->result_name);
|
||||
aggregation_keys.push_back(expression_dag_node->result_name);
|
||||
before_aggregation_actions->actions.getOutputs().push_back(expression_dag_node);
|
||||
before_aggregation_actions->dag.getOutputs().push_back(expression_dag_node);
|
||||
before_aggregation_actions_output_node_names.insert(expression_dag_node->result_name);
|
||||
}
|
||||
}
|
||||
@ -207,7 +207,7 @@ std::optional<AggregationAnalysisResult> analyzeAggregation(const QueryTreeNodeP
|
||||
if (constant_key && !aggregates_descriptions.empty() && (!check_constants_for_group_by_key || canRemoveConstantFromGroupByKey(*constant_key)))
|
||||
continue;
|
||||
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_aggregation_actions->actions, group_by_key_node);
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_aggregation_actions->dag, group_by_key_node);
|
||||
aggregation_keys.reserve(expression_dag_nodes.size());
|
||||
|
||||
for (auto & expression_dag_node : expression_dag_nodes)
|
||||
@ -219,7 +219,7 @@ std::optional<AggregationAnalysisResult> analyzeAggregation(const QueryTreeNodeP
|
||||
auto column_after_aggregation = group_by_use_nulls && expression_dag_node->column != nullptr ? makeNullableSafe(expression_dag_node->column) : expression_dag_node->column;
|
||||
available_columns_after_aggregation.emplace_back(std::move(column_after_aggregation), expression_type_after_aggregation, expression_dag_node->result_name);
|
||||
aggregation_keys.push_back(expression_dag_node->result_name);
|
||||
before_aggregation_actions->actions.getOutputs().push_back(expression_dag_node);
|
||||
before_aggregation_actions->dag.getOutputs().push_back(expression_dag_node);
|
||||
before_aggregation_actions_output_node_names.insert(expression_dag_node->result_name);
|
||||
}
|
||||
}
|
||||
@ -233,13 +233,13 @@ std::optional<AggregationAnalysisResult> analyzeAggregation(const QueryTreeNodeP
|
||||
auto & aggregate_function_node_typed = aggregate_function_node->as<FunctionNode &>();
|
||||
for (const auto & aggregate_function_node_argument : aggregate_function_node_typed.getArguments().getNodes())
|
||||
{
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_aggregation_actions->actions, aggregate_function_node_argument);
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_aggregation_actions->dag, aggregate_function_node_argument);
|
||||
for (auto & expression_dag_node : expression_dag_nodes)
|
||||
{
|
||||
if (before_aggregation_actions_output_node_names.contains(expression_dag_node->result_name))
|
||||
continue;
|
||||
|
||||
before_aggregation_actions->actions.getOutputs().push_back(expression_dag_node);
|
||||
before_aggregation_actions->dag.getOutputs().push_back(expression_dag_node);
|
||||
before_aggregation_actions_output_node_names.insert(expression_dag_node->result_name);
|
||||
}
|
||||
}
|
||||
@ -286,9 +286,9 @@ std::optional<WindowAnalysisResult> analyzeWindow(const QueryTreeNodePtr & query
|
||||
|
||||
PlannerActionsVisitor actions_visitor(planner_context);
|
||||
|
||||
ActionsAndFlagsPtr before_window_actions = std::make_shared<ActionsAndFlags>();
|
||||
before_window_actions->actions = ActionsDAG(input_columns);
|
||||
before_window_actions->actions.getOutputs().clear();
|
||||
ActionsAndProjectInputsFlagPtr before_window_actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
before_window_actions->dag = ActionsDAG(input_columns);
|
||||
before_window_actions->dag.getOutputs().clear();
|
||||
|
||||
std::unordered_set<std::string_view> before_window_actions_output_node_names;
|
||||
|
||||
@ -297,25 +297,25 @@ std::optional<WindowAnalysisResult> analyzeWindow(const QueryTreeNodePtr & query
|
||||
auto & window_function_node_typed = window_function_node->as<FunctionNode &>();
|
||||
auto & window_node = window_function_node_typed.getWindowNode()->as<WindowNode &>();
|
||||
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_window_actions->actions, window_function_node_typed.getArgumentsNode());
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_window_actions->dag, window_function_node_typed.getArgumentsNode());
|
||||
|
||||
for (auto & expression_dag_node : expression_dag_nodes)
|
||||
{
|
||||
if (before_window_actions_output_node_names.contains(expression_dag_node->result_name))
|
||||
continue;
|
||||
|
||||
before_window_actions->actions.getOutputs().push_back(expression_dag_node);
|
||||
before_window_actions->dag.getOutputs().push_back(expression_dag_node);
|
||||
before_window_actions_output_node_names.insert(expression_dag_node->result_name);
|
||||
}
|
||||
|
||||
expression_dag_nodes = actions_visitor.visit(before_window_actions->actions, window_node.getPartitionByNode());
|
||||
expression_dag_nodes = actions_visitor.visit(before_window_actions->dag, window_node.getPartitionByNode());
|
||||
|
||||
for (auto & expression_dag_node : expression_dag_nodes)
|
||||
{
|
||||
if (before_window_actions_output_node_names.contains(expression_dag_node->result_name))
|
||||
continue;
|
||||
|
||||
before_window_actions->actions.getOutputs().push_back(expression_dag_node);
|
||||
before_window_actions->dag.getOutputs().push_back(expression_dag_node);
|
||||
before_window_actions_output_node_names.insert(expression_dag_node->result_name);
|
||||
}
|
||||
|
||||
@ -326,14 +326,14 @@ std::optional<WindowAnalysisResult> analyzeWindow(const QueryTreeNodePtr & query
|
||||
for (auto & sort_node : order_by_node_list.getNodes())
|
||||
{
|
||||
auto & sort_node_typed = sort_node->as<SortNode &>();
|
||||
expression_dag_nodes = actions_visitor.visit(before_window_actions->actions, sort_node_typed.getExpression());
|
||||
expression_dag_nodes = actions_visitor.visit(before_window_actions->dag, sort_node_typed.getExpression());
|
||||
|
||||
for (auto & expression_dag_node : expression_dag_nodes)
|
||||
{
|
||||
if (before_window_actions_output_node_names.contains(expression_dag_node->result_name))
|
||||
continue;
|
||||
|
||||
before_window_actions->actions.getOutputs().push_back(expression_dag_node);
|
||||
before_window_actions->dag.getOutputs().push_back(expression_dag_node);
|
||||
before_window_actions_output_node_names.insert(expression_dag_node->result_name);
|
||||
}
|
||||
}
|
||||
@ -366,8 +366,8 @@ ProjectionAnalysisResult analyzeProjection(const QueryNode & query_node,
|
||||
const PlannerContextPtr & planner_context,
|
||||
ActionsChain & actions_chain)
|
||||
{
|
||||
auto projection_actions = std::make_shared<ActionsAndFlags>();
|
||||
projection_actions->actions = buildActionsDAGFromExpressionNode(query_node.getProjectionNode(), input_columns, planner_context);
|
||||
auto projection_actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
projection_actions->dag = buildActionsDAGFromExpressionNode(query_node.getProjectionNode(), input_columns, planner_context);
|
||||
|
||||
auto projection_columns = query_node.getProjectionColumns();
|
||||
size_t projection_columns_size = projection_columns.size();
|
||||
@ -376,7 +376,7 @@ ProjectionAnalysisResult analyzeProjection(const QueryNode & query_node,
|
||||
NamesWithAliases projection_column_names_with_display_aliases;
|
||||
projection_column_names_with_display_aliases.reserve(projection_columns_size);
|
||||
|
||||
auto & projection_actions_outputs = projection_actions->actions.getOutputs();
|
||||
auto & projection_actions_outputs = projection_actions->dag.getOutputs();
|
||||
size_t projection_outputs_size = projection_actions_outputs.size();
|
||||
|
||||
if (projection_columns_size != projection_outputs_size)
|
||||
@ -414,9 +414,9 @@ SortAnalysisResult analyzeSort(const QueryNode & query_node,
|
||||
const PlannerContextPtr & planner_context,
|
||||
ActionsChain & actions_chain)
|
||||
{
|
||||
auto before_sort_actions = std::make_shared<ActionsAndFlags>();
|
||||
before_sort_actions->actions = ActionsDAG(input_columns);
|
||||
auto & before_sort_actions_outputs = before_sort_actions->actions.getOutputs();
|
||||
auto before_sort_actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
before_sort_actions->dag = ActionsDAG(input_columns);
|
||||
auto & before_sort_actions_outputs = before_sort_actions->dag.getOutputs();
|
||||
before_sort_actions_outputs.clear();
|
||||
|
||||
PlannerActionsVisitor actions_visitor(planner_context);
|
||||
@ -430,7 +430,7 @@ SortAnalysisResult analyzeSort(const QueryNode & query_node,
|
||||
for (const auto & sort_node : order_by_node_list.getNodes())
|
||||
{
|
||||
auto & sort_node_typed = sort_node->as<SortNode &>();
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_sort_actions->actions, sort_node_typed.getExpression());
|
||||
auto expression_dag_nodes = actions_visitor.visit(before_sort_actions->dag, sort_node_typed.getExpression());
|
||||
has_with_fill |= sort_node_typed.withFill();
|
||||
|
||||
for (auto & action_dag_node : expression_dag_nodes)
|
||||
@ -446,7 +446,7 @@ SortAnalysisResult analyzeSort(const QueryNode & query_node,
|
||||
if (has_with_fill)
|
||||
{
|
||||
for (auto & output_node : before_sort_actions_outputs)
|
||||
output_node = &before_sort_actions->actions.materializeNode(*output_node);
|
||||
output_node = &before_sort_actions->dag.materializeNode(*output_node);
|
||||
}
|
||||
|
||||
/// We add only INPUT columns necessary for INTERPOLATE expression in before ORDER BY actions DAG
|
||||
@ -464,7 +464,7 @@ SortAnalysisResult analyzeSort(const QueryNode & query_node,
|
||||
}
|
||||
|
||||
std::unordered_map<std::string_view, const ActionsDAG::Node *> before_sort_actions_inputs_name_to_node;
|
||||
for (const auto & node : before_sort_actions->actions.getInputs())
|
||||
for (const auto & node : before_sort_actions->dag.getInputs())
|
||||
before_sort_actions_inputs_name_to_node.emplace(node->result_name, node);
|
||||
|
||||
for (const auto & node : interpolate_actions_dag.getNodes())
|
||||
@ -477,7 +477,7 @@ SortAnalysisResult analyzeSort(const QueryNode & query_node,
|
||||
if (input_node_it == before_sort_actions_inputs_name_to_node.end())
|
||||
{
|
||||
auto input_column = ColumnWithTypeAndName{node.column, node.result_type, node.result_name};
|
||||
const auto * input_node = &before_sort_actions->actions.addInput(std::move(input_column));
|
||||
const auto * input_node = &before_sort_actions->dag.addInput(std::move(input_column));
|
||||
auto [it, _] = before_sort_actions_inputs_name_to_node.emplace(node.result_name, input_node);
|
||||
input_node_it = it;
|
||||
}
|
||||
@ -502,23 +502,23 @@ LimitByAnalysisResult analyzeLimitBy(const QueryNode & query_node,
|
||||
const NameSet & required_output_nodes_names,
|
||||
ActionsChain & actions_chain)
|
||||
{
|
||||
auto before_limit_by_actions = std::make_shared<ActionsAndFlags>();
|
||||
before_limit_by_actions->actions = buildActionsDAGFromExpressionNode(query_node.getLimitByNode(), input_columns, planner_context);
|
||||
auto before_limit_by_actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
before_limit_by_actions->dag = buildActionsDAGFromExpressionNode(query_node.getLimitByNode(), input_columns, planner_context);
|
||||
|
||||
NameSet limit_by_column_names_set;
|
||||
Names limit_by_column_names;
|
||||
limit_by_column_names.reserve(before_limit_by_actions->actions.getOutputs().size());
|
||||
for (auto & output_node : before_limit_by_actions->actions.getOutputs())
|
||||
limit_by_column_names.reserve(before_limit_by_actions->dag.getOutputs().size());
|
||||
for (auto & output_node : before_limit_by_actions->dag.getOutputs())
|
||||
{
|
||||
limit_by_column_names_set.insert(output_node->result_name);
|
||||
limit_by_column_names.push_back(output_node->result_name);
|
||||
}
|
||||
|
||||
for (const auto & node : before_limit_by_actions->actions.getNodes())
|
||||
for (const auto & node : before_limit_by_actions->dag.getNodes())
|
||||
{
|
||||
if (required_output_nodes_names.contains(node.result_name) &&
|
||||
!limit_by_column_names_set.contains(node.result_name))
|
||||
before_limit_by_actions->actions.getOutputs().push_back(&node);
|
||||
before_limit_by_actions->dag.getOutputs().push_back(&node);
|
||||
}
|
||||
|
||||
auto actions_step_before_limit_by = std::make_unique<ActionsChainStep>(before_limit_by_actions);
|
||||
@ -612,7 +612,7 @@ PlannerExpressionsAnalysisResult buildExpressionAnalysisResult(const QueryTreeNo
|
||||
if (sort_analysis_result_optional.has_value() && planner_query_processing_info.isFirstStage() && planner_query_processing_info.getToStage() != QueryProcessingStage::Complete)
|
||||
{
|
||||
const auto & before_order_by_actions = sort_analysis_result_optional->before_order_by_actions;
|
||||
for (const auto & output_node : before_order_by_actions->actions.getOutputs())
|
||||
for (const auto & output_node : before_order_by_actions->dag.getOutputs())
|
||||
required_output_nodes_names.insert(output_node->result_name);
|
||||
}
|
||||
|
||||
@ -668,9 +668,9 @@ PlannerExpressionsAnalysisResult buildExpressionAnalysisResult(const QueryTreeNo
|
||||
}
|
||||
}
|
||||
|
||||
auto project_names_actions = std::make_shared<ActionsAndFlags>();
|
||||
project_names_actions->actions = ActionsDAG(project_names_input);
|
||||
project_names_actions->actions.project(projection_analysis_result.projection_column_names_with_display_aliases);
|
||||
auto project_names_actions = std::make_shared<ActionsAndProjectInputsFlag>();
|
||||
project_names_actions->dag = ActionsDAG(project_names_input);
|
||||
project_names_actions->dag.project(projection_analysis_result.projection_column_names_with_display_aliases);
|
||||
project_names_actions->project_input = true;
|
||||
actions_chain.addStep(std::make_unique<ActionsChainStep>(project_names_actions));
|
||||
|
||||
|
@ -17,22 +17,22 @@ namespace DB
|
||||
|
||||
struct ProjectionAnalysisResult
|
||||
{
|
||||
ActionsAndFlagsPtr projection_actions;
|
||||
ActionsAndProjectInputsFlagPtr projection_actions;
|
||||
Names projection_column_names;
|
||||
NamesWithAliases projection_column_names_with_display_aliases;
|
||||
ActionsAndFlagsPtr project_names_actions;
|
||||
ActionsAndProjectInputsFlagPtr project_names_actions;
|
||||
};
|
||||
|
||||
struct FilterAnalysisResult
|
||||
{
|
||||
ActionsAndFlagsPtr filter_actions;
|
||||
ActionsAndProjectInputsFlagPtr filter_actions;
|
||||
std::string filter_column_name;
|
||||
bool remove_filter_column = false;
|
||||
};
|
||||
|
||||
struct AggregationAnalysisResult
|
||||
{
|
||||
ActionsAndFlagsPtr before_aggregation_actions;
|
||||
ActionsAndProjectInputsFlagPtr before_aggregation_actions;
|
||||
Names aggregation_keys;
|
||||
AggregateDescriptions aggregate_descriptions;
|
||||
GroupingSetsParamsList grouping_sets_parameters_list;
|
||||
@ -41,19 +41,19 @@ struct AggregationAnalysisResult
|
||||
|
||||
struct WindowAnalysisResult
|
||||
{
|
||||
ActionsAndFlagsPtr before_window_actions;
|
||||
ActionsAndProjectInputsFlagPtr before_window_actions;
|
||||
std::vector<WindowDescription> window_descriptions;
|
||||
};
|
||||
|
||||
struct SortAnalysisResult
|
||||
{
|
||||
ActionsAndFlagsPtr before_order_by_actions;
|
||||
ActionsAndProjectInputsFlagPtr before_order_by_actions;
|
||||
bool has_with_fill = false;
|
||||
};
|
||||
|
||||
struct LimitByAnalysisResult
|
||||
{
|
||||
ActionsAndFlagsPtr before_limit_by_actions;
|
||||
ActionsAndProjectInputsFlagPtr before_limit_by_actions;
|
||||
Names limit_by_column_names;
|
||||
};
|
||||
|
||||
|
@ -77,7 +77,7 @@ static AggregateProjectionInfo getAggregatingProjectionInfo(
|
||||
|
||||
AggregateProjectionInfo info;
|
||||
info.context = interpreter.getContext();
|
||||
info.before_aggregation = analysis_result.before_aggregation->actions.clone();
|
||||
info.before_aggregation = analysis_result.before_aggregation->dag.clone();
|
||||
info.keys = query_analyzer->aggregationKeys().getNames();
|
||||
info.aggregates = query_analyzer->aggregates();
|
||||
|
||||
|
@ -7061,7 +7061,7 @@ ActionDAGNodes MergeTreeData::getFiltersForPrimaryKeyAnalysis(const InterpreterS
|
||||
filter_nodes.nodes.push_back(&additional_filter_info->actions->findInOutputs(additional_filter_info->column_name));
|
||||
|
||||
if (before_where)
|
||||
filter_nodes.nodes.push_back(&before_where->actions.findInOutputs(where_column_name));
|
||||
filter_nodes.nodes.push_back(&before_where->dag.findInOutputs(where_column_name));
|
||||
|
||||
return filter_nodes;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user