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

Function formatNodePretty

src/Processors/QueryPlan/QueryPlanFormat.cpp:306–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304 }
305
306 String formatNodePretty(
307 const ActionsDAG::Node * node,
308 const std::unordered_map<String, PrettyColumnName> & pretty_names,
309 const std::unordered_map<String, RuntimeFilterInfo> & runtime_filter_names,
310 std::unordered_map<FutureSet::Hash, String, PreparedSets::Hashing> & subquery_set_names,
311 int parent_precedence)
312 {
313 using ActionType = ActionsDAG::ActionType;
314
315 switch (node->type)
316 {
317 case ActionType::INPUT:
318 {
319 if (auto it = pretty_names.find(node->result_name); it != pretty_names.end())
320 return it->second.expression;
321 return trimColumnIdentifier(node->result_name);
322 }
323
324 case ActionType::COLUMN:
325 return formatConstant(node);
326 case ActionType::ALIAS:
327 return formatNodePretty(node->children.front(), pretty_names, runtime_filter_names, subquery_set_names, parent_precedence);
328
329 case ActionType::ARRAY_JOIN:
330 return "arrayJoin(" + formatNodePretty(node->children.front(), pretty_names, runtime_filter_names, subquery_set_names) + ")";
331
332 case ActionType::FUNCTION:
333 {
334 auto func_name = node->function_base->getName();
335
336 if (func_name == "__applyFilter")
337 {
338 String filter_id = getRuntimeFilterId(node);
339 const auto * probe_node = node->children[1];
340 String probe_column;
341 if (auto pit = pretty_names.find(probe_node->result_name); pit != pretty_names.end())
342 probe_column = pit->second.expression;
343 else
344 probe_column = trimColumnIdentifier(probe_node->result_name);
345
346 if (auto it = runtime_filter_names.find(filter_id); it != runtime_filter_names.end())
347 {
348 const auto & pretty_filter_name = it->second.pretty_name;
349 const auto & build_column = it->second.build_column_name;
350 const auto & build_table = it->second.build_table_name;
351 if (build_table.empty())
352 return fmt::format("{}({}, {})", pretty_filter_name, probe_column, build_column);
353 return fmt::format("{}({}, {} from {})", pretty_filter_name, probe_column, build_column, build_table);
354 }
355 return fmt::format("{}({})", filter_id, probe_column);
356 }
357
358 if ((func_name == "_CAST" || func_name == "CAST") && node->children.size() == 2)
359 {
360 auto inner = formatNodePretty(node->children[0], pretty_names, runtime_filter_names, subquery_set_names);
361 Field type_field;
362 node->children[1]->column->get(0, type_field);
363 return "CAST(" + inner + " AS " + type_field.safeGet<String>() + ")";

Callers 2

formatFilterPrettyFunction · 0.85
buildPrettyNamesForNodeFunction · 0.85

Calls 15

trimColumnIdentifierFunction · 0.85
formatConstantFunction · 0.85
getRuntimeFilterIdFunction · 0.85
getOperatorInfoFunction · 0.85
formatSetPrettyFunction · 0.85
formatFunction · 0.50
findMethod · 0.45
endMethod · 0.45
frontMethod · 0.45
getNameMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected