MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / finalize

Method finalize

src/Interpreters/ExpressionActions.cpp:1045–1084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1043}
1044
1045void ExpressionActionsChain::finalize()
1046{
1047 /// Finalize all steps. Right to left to define unnecessary input columns.
1048 for (int i = static_cast<int>(steps.size()) - 1; i >= 0; --i)
1049 {
1050 auto & required_output = steps[i]->required_output;
1051 NameSet required_names;
1052 for (const auto & output : required_output)
1053 required_names.insert(output.first);
1054
1055 if (i + 1 < static_cast<int>(steps.size()))
1056 {
1057 const NameSet & additional_input = steps[i + 1]->additional_input;
1058 for (const auto & it : steps[i + 1]->getRequiredColumns())
1059 {
1060 if (!additional_input.contains(it.name))
1061 {
1062 auto iter = required_output.find(it.name);
1063 if (iter == required_output.end())
1064 required_names.insert(it.name);
1065 else
1066 iter->second = false;
1067 }
1068 }
1069 }
1070 steps[i]->finalize(required_names);
1071 }
1072
1073 /// Adding the ejection of unnecessary columns to the beginning of each step.
1074 for (size_t i = 1; i < steps.size(); ++i)
1075 {
1076 size_t columns_from_previous = steps[i - 1]->getResultColumns().size();
1077
1078 /// If unnecessary columns are formed at the output of the previous step, we'll add them to the beginning of this step.
1079 /// Except when we drop all the columns and lose the number of rows in the block.
1080 if (!steps[i]->getResultColumns().empty()
1081 && columns_from_previous > steps[i]->getRequiredColumns().size())
1082 steps[i]->prependProjectInput();
1083 }
1084}
1085
1086ExpressionActionsChainSteps::ExpressionActionsStep * ExpressionActionsChain::getLastExpressionStep(bool allow_empty)
1087{

Callers 15

executeQueryFunction · 0.45
saveModuleMethod · 0.45
loadModuleImplMethod · 0.45
prepareMutationStagesMethod · 0.45
~TraceCollectorMethod · 0.45
ContextSharedPartClass · 0.45
reconnectZooKeeperMethod · 0.45
setResultMethod · 0.45
executeImplMethod · 0.45
finalizeImplMethod · 0.45

Calls 14

condColumnNamesMethod · 0.80
swapFunction · 0.50
sizeMethod · 0.45
insertMethod · 0.45
getRequiredColumnsMethod · 0.45
containsMethod · 0.45
findMethod · 0.45
endMethod · 0.45
getResultColumnsMethod · 0.45
emptyMethod · 0.45
prependProjectInputMethod · 0.45
emplace_backMethod · 0.45

Tested by 1

TEST_FFunction · 0.36